<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.studio
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: data.RepositoryModelElementProperty.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefRepositoryModelElementProperty")) {
//-------------------------------------------------------------------------
// Define
define("DefRepositoryModelElementProperty", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . DATAROWOBJECT);
@require_once (FRAMEWORK_DIR . "./filters/filter.forminput.php");
@require_once (FRAMEWORK_DIR . "./validators/validator.identifier.php");
//-------------------------------------------------------------------------
// Class
class RepositoryModelElementProperty extends DataRow {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer RepositoryModelElementProperty REPMEPRPKID primary key
*/
function RepositoryModelElementProperty($REPMEPRPKID = 0) {
//
$this->m_tableSet[PRIMARYKEY] = "tbl_repository_model_element_property";
//
$this->m_indexSet[PRIMARYKEY] = "REPMEPRPKID";
$this->m_indexSet[FOREIGNKEY] = array(
"REPMELTPKID",
"DICPROPPKID"
);
$this->m_indexSet[NATURALKEY] = "DICPROPNAME";
//
$this->m_fieldSet["REPMEPRPKID"] = $REPMEPRPKID;
}
//-------------------------------------------------------------------------
// Methods
/**
*
* @param integer index type
* @param integer order type
* @param integer order mode
* @return string
*/
function getInsertQuery($indexType = FOREIGNKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
$insertSQL = "INSERT INTO $table ( ";
$valuesSQL = "VALUES ( ";
// REPMELTPKID RepositoryModelElementType foreign key
$value = $this->m_fieldSet["REPMELTPKID"];
if (!empty($value)) {
$insertSQL.= " REPMELTPKID";
$valuesSQL.= " $value";
} else {
$this->m_errorSet["REPMELTPKID"] = true;
return ("");
}
// DICPROPPKID DictionaryProperty foreign key
$value = $this->m_fieldSet["DICPROPPKID"];
if (!empty($value)) {
$insertSQL.= " ,DICPROPPKID";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["DICPROPPKID"] = true;
return ("");
}
// REPMEPRTEXT = RepositoryModelElementProperty description
$value = FilterFormInput::filter($this->m_fieldSet["REPMEPRTEXT"], true);
if ($value != "") {
$insertSQL.= " ,REPMEPRTEXT";
$valuesSQL.= " ,$value";
}
// REPMEPRDATE = RepositoryModelElementProperty creation date
$value = Date("Y-m-d H:i:s");
$insertSQL.= " ,REPMEPRDATE";
$valuesSQL.= " ,\"$value\"";
// REPMEPRSTAT = RepositoryModelElementProperty status
$value = 1;
$insertSQL.= " ,REPMEPRSTAT";
$valuesSQL.= " ,$value";
// REPMEPRTYPE = RepositoryModelElementProperty type
$value = $this->m_fieldSet["REPMEPRTYPE"];
if (!empty($value)) {
$insertSQL.= " ,REPMEPRTYPE";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["REPMEPRTYPE"] = true;
return ("");
}
//
return ($insertSQL . ") " . $valuesSQL . ")");
}
/**
*
* @param integer index type
* @return string
*/
function getUpdateQuery($indexType = PRIMARYKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
switch ($indexType) {
case PRIMARYKEY:
/*
* UPDATE
* tbl_repository_model_element_property
* ON
* REPMEPRPKID
*
*/
//
$field = $this->m_indexSet[PRIMARYKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) {
//
$updateSQL = "UPDATE $table SET ";
// REPMEPRTEXT = RepositoryModelElementProperty description
$value = FilterFormInput::filter($this->m_fieldSet["REPMEPRTEXT"], true);
$updateSQL.= " REPMEPRTEXT=$value";
// REPMEPRSTAT = RepositoryModelElementProperty status
$value = $this->m_fieldSet["REPMEPRSTAT"];
$updateSQL.= ",REPMEPRSTAT=$value";
// REPMEPRTYPE = RepositoryCoreElementProperty type
$value = $this->m_fieldSet["REPMEPRTYPE"];
if (!empty($value)) $updateSQL.= ",REPMEPRTYPE=$value";
//
return ($updateSQL . " WHERE $field=$index");
}
break;
case DISPLAYKEY:
/*
* UPDATE
* tbl_repository_model_element_property
* SET
* REPMELTPKID= -REPMEPRPKID
* REPMEPRSTAT=0
* ON
* REPMEPRPKID
*
*/
//
$field = $this->m_indexSet[PRIMARYKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) return ("UPDATE $table
SET
REPMELTPKID= -REPMEPRPKID,
REPMEPRSTAT=0
WHERE
$field=$index
AND
REPMEPRSTAT=1");
break;
}
//
return ("");
}
/**
*
* @param integer index type
* @return string
*/
function getSelectQuery($indexType = PRIMARYKEY) {
//
switch ($indexType) {
case PRIMARYKEY:
/*
* SELECT
* tbl_repository_model_element_property as t1
* <-> tbl_repository_model_element_type as t2
* <-> tbl_dictionary_property as t3
* ON
* REPMEPRPKID
*
*/
//
$index = $this->m_fieldSet["REPMEPRPKID"];
if ($index != 0) return ("SELECT
t1.*,
t2.REPCELTPKID,
t2.REPMELTNAME,
t2.REPMELTCODE,
t3.DICPROPNAME,
t3.DICPROPCODE
FROM
tbl_repository_model_element_property as t1,
tbl_repository_model_element_type as t2,
tbl_dictionary_property as t3
WHERE
t1.REPMEPRPKID=$index
AND
t1.REPMELTPKID=t2.REPMELTPKID
AND
t1.DICPROPPKID=t3.DICPROPPKID
AND
t3.DICPROPSTAT>0");
//
break;
case FOREIGNKEY:
/*
* SELECT
* tbl_repository_model_element_property as t1
* ON
* REPMELTPKID & DICPROPPKID
*
*/
//
$index1 = $this->m_fieldSet["REPMELTPKID"];
$index2 = $this->m_fieldSet["DICPROPPKID"];
if (($index1 != 0) && ($index2 != 0)) return ("SELECT
t1.*
FROM
tbl_repository_model_element_property as t1
WHERE
t1.REPMELTPKID=$index1
AND
t1.DICPROPPKID=$index2
AND
t1.REPMEPRSTAT>0");
//
break;
}
//
return ("");
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>