#128 Allow a blob to be undefined (optional property)

SVN:trunk[427]
This commit is contained in:
Romain Quetiez
2010-05-31 14:51:37 +00:00
parent 8c2d819920
commit 024f67b1b8
2 changed files with 19 additions and 3 deletions

View File

@@ -342,7 +342,9 @@ class bizDocument extends logRealObject
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum("documentation,contract,working instructions,network map,white paper,presentation,training"), "sql"=>"type", "default_value"=>"documentation", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBlob("contents", array("depends_on"=>array())));
// MetaModel::Init_AddAttribute(new AttributeBlob("contents", array("depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBlob("contents", array("is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'type', 'description', 'contents')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'type', 'contents')); // Attributes to be displayed for a list

View File

@@ -80,6 +80,18 @@ abstract class AttributeDefinition
private $m_sHostClass = '!undefined!';
protected function Get($sParamName) {return $this->m_aParams[$sParamName];}
protected function IsParam($sParamName) {return (array_key_exists($sParamName, $this->m_aParams));}
protected function GetOptional($sParamName, $default)
{
if (array_key_exists($sParamName, $this->m_aParams))
{
return $this->m_aParams[$sParamName];
}
else
{
return $default;
}
}
public function __construct($sCode, $aParams)
{
@@ -353,6 +365,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
public function GetDefaultValue() {return "";}
public function IsNullAllowed() {return false;}
//
protected function ScalarToSQL($value) {return $value;} // format value as a valuable SQL literal (quoted outside)
public function GetSQLExpressions()
@@ -423,7 +436,7 @@ class AttributeDBField extends AttributeDBFieldVoid
return array_merge(parent::ListExpectedParams(), array("default_value", "is_null_allowed"));
}
public function GetDefaultValue() {return $this->Get("default_value");}
public function IsNullAllowed() {return strtolower($this->Get("is_null_allowed"));}
public function IsNullAllowed() {return $this->Get("is_null_allowed");}
}
/**
@@ -1526,7 +1539,8 @@ class AttributeBlob extends AttributeDefinition
public function IsScalar() {return true;}
public function IsWritable() {return true;}
public function GetDefaultValue() {return "";}
public function IsNullAllowed() {return false;}
public function IsNullAllowed() {return $this->GetOptional("is_null_allowed", false);}
// Facilitate things: allow the user to Set the value from a string
public function MakeRealValue($proposedValue)