[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14621] formatting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14621] formatting |
Date: |
Tue, 05 Jan 2016 08:48:25 +0000 |
Revision: 14621
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14621
Author: sigurdne
Date: 2016-01-05 08:48:25 +0000 (Tue, 05 Jan 2016)
Log Message:
-----------
formatting
Modified Paths:
--------------
branches/dev-syncromind/bim/inc/class.bimExceptions.inc.php
branches/dev-syncromind/bim/inc/class.bimitem.inc.php
branches/dev-syncromind/bim/inc/class.bimmodel.inc.php
branches/dev-syncromind/bim/inc/class.bimmodelinformation.inc.php
branches/dev-syncromind/bim/inc/class.bimobject.inc.php
branches/dev-syncromind/bim/inc/class.boattribute.inc.php
branches/dev-syncromind/bim/inc/class.boattribute_owner.inc.php
branches/dev-syncromind/bim/inc/class.bobimitem.inc.php
branches/dev-syncromind/bim/inc/class.bobimmodel.inc.php
branches/dev-syncromind/bim/inc/class.bogroup.inc.php
branches/dev-syncromind/bim/inc/class.boitem.inc.php
branches/dev-syncromind/bim/inc/class.menu.inc.php
branches/dev-syncromind/bim/inc/class.restrequest.inc.php
branches/dev-syncromind/bim/inc/class.sobim.inc.php
branches/dev-syncromind/bim/inc/class.sobim_converter.inc.php
branches/dev-syncromind/bim/inc/class.sobim_repository.inc.php
branches/dev-syncromind/bim/inc/class.sobimitem.inc.php
branches/dev-syncromind/bim/inc/class.sobimmodel.inc.php
branches/dev-syncromind/bim/inc/class.sobimmodelinformation.inc.php
branches/dev-syncromind/bim/inc/class.sobimtype.inc.php
branches/dev-syncromind/bim/inc/class.soitem.inc.php
branches/dev-syncromind/bim/inc/class.soitem_group.inc.php
branches/dev-syncromind/bim/inc/class.sovfs.inc.php
branches/dev-syncromind/bim/inc/class.uibim.inc.php
branches/dev-syncromind/bim/inc/class.uibimitem.inc.php
branches/dev-syncromind/bim/inc/class.uiifc.inc.php
branches/dev-syncromind/bim/inc/class.uiitem.inc.php
branches/dev-syncromind/bim/index.php
branches/dev-syncromind/bim/setup/setup.inc.php
branches/dev-syncromind/bim/setup/tables_current.inc.php
branches/dev-syncromind/bim/setup/tables_update.inc.php
branches/dev-syncromind/bim/templates/base/app_data.xsl
branches/dev-syncromind/bim/templates/base/bim_modelinformation.xsl
branches/dev-syncromind/bim/templates/base/bim_showSingleItem.xsl
branches/dev-syncromind/bim/templates/base/bim_upload_ifc_result.xsl
branches/dev-syncromind/bim/templates/base/config.tpl
branches/dev-syncromind/bim/templates/base/css/bim.css
branches/dev-syncromind/bim/tests/BIM/PropertyBimTestSuite.php
branches/dev-syncromind/bim/tests/BIM/TestBObimitem.php
branches/dev-syncromind/bim/tests/BIM/TestBObimmodel.php
branches/dev-syncromind/bim/tests/BIM/TestBimCommon.php
branches/dev-syncromind/bim/tests/BIM/TestBimmodelinformation_solo.php
branches/dev-syncromind/bim/tests/BIM/TestSObim_converter_solo.php
branches/dev-syncromind/bim/tests/BIM/TestSObim_solo.php
branches/dev-syncromind/bim/tests/BIM/TestSObimitem.php
branches/dev-syncromind/bim/tests/BIM/TestSObimmodel.php
branches/dev-syncromind/bim/tests/BIM/TestSObimmodelinformation.php
branches/dev-syncromind/bim/tests/BIM/TestSObimrest_solo.php
branches/dev-syncromind/bim/tests/BIM/TestSObimtype.php
branches/dev-syncromind/bim/tests/BIM/TestSOvfs.php
branches/dev-syncromind/bim/tests/BIM/TestUIbim.php
branches/dev-syncromind/bim/tests/BIM/testData.xml
branches/dev-syncromind/bim/tests/BIM/wholeModelOutputExample.xml
Modified: branches/dev-syncromind/bim/inc/class.bimExceptions.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bimExceptions.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bimExceptions.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,64 +1,99 @@
<?php
-class FileExistsException extends Exception
-{
- public function __construct($message, $code = 0) {
- parent::__construct($message, $code);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class CopyFailureException extends Exception
-{
- public function __construct($message, $code = 0) {
- parent::__construct($message, $code);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class ModelExistsException extends Exception
-{
- public function __construct($message, $code = 0) {
- parent::__construct($message, $code);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class ModelDoesNotExistException extends Exception
-{
- public function __construct($message, Exception $previous = null) {
- parent::__construct($message, 0, $previous);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class IncompleteItemException extends Exception
-{
- public function __construct($message, $code = 0) {
- parent::__construct($message, $code);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class BimDataException extends Exception
-{
- public function __construct($message, Exception $previous = null) {
- parent::__construct($message, 0, $previous);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
-class NoResponseException extends Exception
-{
- public function __construct($message, Exception $previous = null) {
- parent::__construct($message, 0, $previous);
- }
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
-}
\ No newline at end of file
+
+ class FileExistsException extends Exception
+ {
+
+ public function __construct($message, $code = 0)
+ {
+ parent::__construct($message, $code);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class CopyFailureException extends Exception
+ {
+
+ public function __construct($message, $code = 0)
+ {
+ parent::__construct($message, $code);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class ModelExistsException extends Exception
+ {
+
+ public function __construct($message, $code = 0)
+ {
+ parent::__construct($message, $code);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class ModelDoesNotExistException extends Exception
+ {
+
+ public function __construct($message, Exception $previous =
null)
+ {
+ parent::__construct($message, 0, $previous);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class IncompleteItemException extends Exception
+ {
+
+ public function __construct($message, $code = 0)
+ {
+ parent::__construct($message, $code);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class BimDataException extends Exception
+ {
+
+ public function __construct($message, Exception $previous =
null)
+ {
+ parent::__construct($message, 0, $previous);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
+
+ class NoResponseException extends Exception
+ {
+
+ public function __construct($message, Exception $previous =
null)
+ {
+ parent::__construct($message, 0, $previous);
+ }
+
+ public function __toString()
+ {
+ return __CLASS__ . ": [{$this->code}]:
{$this->message}\n";
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bimitem.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bimitem.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bimitem.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,46 +1,67 @@
<?php
-phpgw::import_class('bim.bimobject');
-class BimItem extends BimObject{
- private $databaseId;
- private $guid;
- private $type;
- private $xml;
- private $modelId;
-
- function __construct($databaseId = null, $guid = null, $type = null,
$xml = null, $modelId = null) {
- //$this->databaseId = (is_null($databaseId)) ? null :
(int)$databaseId;
- $this->databaseId = (int)$databaseId;
- $this->guid = $guid;
- $this->type = $type;
- $this->xml = $xml;
- $this->modelId = $modelId;
- }
- function getDatabaseId() {
- return $this->databaseId;
- }
- function setDatabaseId($databaseId) {
- $this->databaseId = $databaseId;
- }
- function getGuid() {
- return $this->guid;
- }
- function getType() {
- return $this->type;
- }
- function setType($type) {
- $this->type = $type;
- }
- function getXml() {
- return $this->xml;
- }
- function setXml($xml) {
- $this->xml = $xml;
- }
- function getModelId() {
- return $this->modelId;
- }
- function setModelId($id) {
- $this->modelId = $id;
- }
-
-}
+ phpgw::import_class('bim.bimobject');
+
+ class BimItem extends BimObject
+ {
+
+ private $databaseId;
+ private $guid;
+ private $type;
+ private $xml;
+ private $modelId;
+
+ function __construct($databaseId = null, $guid = null, $type =
null, $xml = null, $modelId = null)
+ {
+ //$this->databaseId = (is_null($databaseId)) ? null :
(int)$databaseId;
+ $this->databaseId = (int)$databaseId;
+ $this->guid = $guid;
+ $this->type = $type;
+ $this->xml = $xml;
+ $this->modelId = $modelId;
+ }
+
+ function getDatabaseId()
+ {
+ return $this->databaseId;
+ }
+
+ function setDatabaseId($databaseId)
+ {
+ $this->databaseId = $databaseId;
+ }
+
+ function getGuid()
+ {
+ return $this->guid;
+ }
+
+ function getType()
+ {
+ return $this->type;
+ }
+
+ function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ function getXml()
+ {
+ return $this->xml;
+ }
+
+ function setXml($xml)
+ {
+ $this->xml = $xml;
+ }
+
+ function getModelId()
+ {
+ return $this->modelId;
+ }
+
+ function setModelId($id)
+ {
+ $this->modelId = $id;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bimmodel.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bimmodel.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bimmodel.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,77 +1,115 @@
<?php
-phpgw::import_class('bim.bimobject');
-class BimModel extends BimObject{
- private $databaseId;
- private $name;
- private $creationDate;
- private $fileSize;
- private $fileName;
- private $usedItemCount;
- private $vfsFileId;
- private $used;
-
- function __construct($databaseId = null, $name = null, $creationDate =
null, $fileSize = null,$fileName= null,$usedItemCount= null, $vfsFileId = null)
{
- $this->databaseId = (int)$databaseId;
- $this->name = $name;
- $this->creationDate = $creationDate;
- $this->fileSize = $fileSize;
- $this->fileName = $fileName;
- $this->usedItemCount = $usedItemCount;
- if($usedItemCount && $usedItemCount > 0) {
- $this->used = true;
- } else {
- $this->used = false;
+ phpgw::import_class('bim.bimobject');
+
+ class BimModel extends BimObject
+ {
+
+ private $databaseId;
+ private $name;
+ private $creationDate;
+ private $fileSize;
+ private $fileName;
+ private $usedItemCount;
+ private $vfsFileId;
+ private $used;
+
+ function __construct($databaseId = null, $name = null,
$creationDate = null, $fileSize = null, $fileName = null, $usedItemCount =
null, $vfsFileId = null)
+ {
+ $this->databaseId = (int)$databaseId;
+ $this->name = $name;
+ $this->creationDate = $creationDate;
+ $this->fileSize = $fileSize;
+ $this->fileName = $fileName;
+ $this->usedItemCount = $usedItemCount;
+ if($usedItemCount && $usedItemCount > 0)
+ {
+ $this->used = true;
+ }
+ else
+ {
+ $this->used = false;
+ }
}
-
- }
- function getDatabaseId() {
- return $this->databaseId;
- }
- function setDatabaseId($databaseId) {
- $this->databaseId = $databaseId;
- }
- function getName() {
- return $this->name;
- }
- function setName($item) {
- $this->name = $item;
- }
- function getCreationDate() {
- return $this->creationDate;
- }
- function setCreationDate($item) {
- $this->creationDate = $item;
- }
- function getFileSize() {
- return $this->fileSize;
- }
- function setFileSize($item) {
- $this->fileSize = $item;
- }
- function getFileName() {
- return $this->fileName;
- }
- function setFileName($item) {
- $this->fileName = $item;
- }
- function getUsedItemCount() {
- return $this->usedItemCount;
- }
- function setUsedItemCount($item) {
- $this->usedItemCount = $item;
- }
- function getVfsFileId() {
- return $this->vfsFileId;
- }
- function setVfsFileId($item) {
- $this->vfsFileId = $item;
- }
-
- function getUsed() {
- if($this->used) {
- return $this->used;
- } else {
- return (bool)($this->usedItemCount > 0);
+
+ function getDatabaseId()
+ {
+ return $this->databaseId;
}
- }
-}
+
+ function setDatabaseId($databaseId)
+ {
+ $this->databaseId = $databaseId;
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+
+ function setName($item)
+ {
+ $this->name = $item;
+ }
+
+ function getCreationDate()
+ {
+ return $this->creationDate;
+ }
+
+ function setCreationDate($item)
+ {
+ $this->creationDate = $item;
+ }
+
+ function getFileSize()
+ {
+ return $this->fileSize;
+ }
+
+ function setFileSize($item)
+ {
+ $this->fileSize = $item;
+ }
+
+ function getFileName()
+ {
+ return $this->fileName;
+ }
+
+ function setFileName($item)
+ {
+ $this->fileName = $item;
+ }
+
+ function getUsedItemCount()
+ {
+ return $this->usedItemCount;
+ }
+
+ function setUsedItemCount($item)
+ {
+ $this->usedItemCount = $item;
+ }
+
+ function getVfsFileId()
+ {
+ return $this->vfsFileId;
+ }
+
+ function setVfsFileId($item)
+ {
+ $this->vfsFileId = $item;
+ }
+
+ function getUsed()
+ {
+ if($this->used)
+ {
+ return $this->used;
+ }
+ else
+ {
+ return (bool)($this->usedItemCount > 0);
+ }
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bimmodelinformation.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bimmodelinformation.inc.php
2016-01-05 08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bimmodelinformation.inc.php
2016-01-05 08:48:25 UTC (rev 14621)
@@ -1,127 +1,159 @@
<?php
-phpgw::import_class('bim.bimobject');
+ phpgw::import_class('bim.bimobject');
-class BimModelInformation extends BimObject{
- private $authorization;
- private $author;
- private $changeDate;
- private $description;
- private $organization;
- private $originatingSystem;
- private $preProcessor;
- private $valDate;
- private $nativeSchema;
+ class BimModelInformation extends BimObject
+ {
- public function loadVariablesFromXml(SimpleXMLElement
$modelInformation) {
- if(!empty($modelInformation->authorization)){
-
$this->setAuthorization((string)$modelInformation->authorization);
+ private $authorization;
+ private $author;
+ private $changeDate;
+ private $description;
+ private $organization;
+ private $originatingSystem;
+ private $preProcessor;
+ private $valDate;
+ private $nativeSchema;
+
+ public function loadVariablesFromXml(SimpleXMLElement
$modelInformation)
+ {
+ if(!empty($modelInformation->authorization))
+ {
+
$this->setAuthorization((string)$modelInformation->authorization);
+ }
+ if(!empty($modelInformation->author))
+ {
+
$this->setAuthor((string)$modelInformation->author);
+ }
+ if(!empty($modelInformation->changeDate))
+ {
+
$this->setChangeDate($modelInformation->changeDate);
+ }
+ if(!empty($modelInformation->valDate))
+ {
+ $this->setValDate($modelInformation->valDate);
+ }
+ if(!empty($modelInformation->description))
+ {
+
$this->setDescription((string)$modelInformation->description);
+ }
+ if(!empty($modelInformation->organization))
+ {
+
$this->setOrganization((string)$modelInformation->organization);
+ }
+ if(!empty($modelInformation->originatingSystem))
+ {
+
$this->setOriginatingSystem((string)$modelInformation->originatingSystem);
+ }
+ if(!empty($modelInformation->originatingSystem))
+ {
+
$this->setOriginatingSystem((string)$modelInformation->originatingSystem);
+ }
+ if(!empty($modelInformation->preProcessor))
+ {
+
$this->setPreProcessor((string)$modelInformation->preProcessor);
+ }
+ if(!empty($modelInformation->nativeSchema))
+ {
+
$this->setNativeSchema((string)$modelInformation->nativeSchema);
+ }
}
- if(!empty($modelInformation->author)) {
- $this->setAuthor((string)$modelInformation->author);
+ /*
+ * Converts ISO8601 string to timestamp
+ * Not needed, postgres accepts iso8601 as input
+ */
+
+ public function convertToTimestamp($iso8601date)
+ {
+ return strtotime($iso8601date);
}
- if(!empty($modelInformation->changeDate)) {
- $this->setChangeDate($modelInformation->changeDate);
+
+ public function getOrganization()
+ {
+ return $this->organization;
}
- if(!empty($modelInformation->valDate)) {
- $this->setValDate($modelInformation->valDate);
+
+ public function setOrganization($organization)
+ {
+ $this->organization = $organization;
}
- if(!empty($modelInformation->description)) {
-
$this->setDescription((string)$modelInformation->description);
+
+ public function getOriginatingSystem()
+ {
+ return $this->originatingSystem;
}
- if(!empty($modelInformation->organization)) {
-
$this->setOrganization((string)$modelInformation->organization);
+
+ public function setOriginatingSystem($originatingSystem)
+ {
+ $this->originatingSystem = $originatingSystem;
}
- if(!empty($modelInformation->originatingSystem)) {
-
$this->setOriginatingSystem((string)$modelInformation->originatingSystem);
+
+ public function getPreProcessor()
+ {
+ return $this->preProcessor;
}
- if(!empty($modelInformation->originatingSystem)) {
-
$this->setOriginatingSystem((string)$modelInformation->originatingSystem);
+
+ public function setPreProcessor($preProcessor)
+ {
+ $this->preProcessor = $preProcessor;
}
- if(!empty($modelInformation->preProcessor)) {
-
$this->setPreProcessor((string)$modelInformation->preProcessor);
+
+ public function getAuthorization()
+ {
+ return $this->authorization;
}
- if(!empty($modelInformation->nativeSchema)) {
-
$this->setNativeSchema((string)$modelInformation->nativeSchema);
+
+ public function setAuthorization($authorization)
+ {
+ $this->authorization = $authorization;
}
- }
- /*
- *Converts ISO8601 string to timestamp
- * Not needed, postgres accepts iso8601 as input
- */
- public function convertToTimestamp($iso8601date) {
- return strtotime($iso8601date);
- }
+ public function getAuthor()
+ {
+ return $this->author;
+ }
- public function getOrganization() {
- return $this->organization;
- }
+ public function setAuthor($author)
+ {
+ $this->author = $author;
+ }
- public function setOrganization($organization) {
- $this->organization = $organization;
- }
+ public function getChangeDate()
+ {
+ return $this->changeDate;
+ }
- public function getOriginatingSystem() {
- return $this->originatingSystem;
- }
+ public function setChangeDate($changeDate)
+ {
+ $this->changeDate = $changeDate;
+ }
- public function setOriginatingSystem($originatingSystem) {
- $this->originatingSystem = $originatingSystem;
- }
+ public function getDescription()
+ {
+ return $this->description;
+ }
- public function getPreProcessor() {
- return $this->preProcessor;
- }
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ }
- public function setPreProcessor($preProcessor) {
- $this->preProcessor = $preProcessor;
- }
+ public function getValDate()
+ {
+ return $this->valDate;
+ }
- public function getAuthorization() {
- return $this->authorization;
- }
+ public function setValDate($valDate)
+ {
+ $this->valDate = $valDate;
+ }
- public function setAuthorization($authorization) {
- $this->authorization = $authorization;
- }
+ public function setNativeSchema($nativeSchema)
+ {
+ $this->nativeSchema = $nativeSchema;
+ }
- public function getAuthor() {
- return $this->author;
- }
-
- public function setAuthor($author) {
- $this->author = $author;
- }
-
- public function getChangeDate() {
- return $this->changeDate;
- }
-
- public function setChangeDate($changeDate) {
- $this->changeDate = $changeDate;
- }
-
- public function getDescription() {
- return $this->description;
- }
-
- public function setDescription($description) {
- $this->description = $description;
- }
-
- public function getValDate() {
- return $this->valDate;
- }
-
- public function setValDate($valDate) {
- $this->valDate = $valDate;
- }
-
- public function setNativeSchema($nativeSchema) {
- $this->nativeSchema = $nativeSchema;
- }
-
- public function getNativeSchema() {
- return $this->nativeSchema;
- }
-}
+ public function getNativeSchema()
+ {
+ return $this->nativeSchema;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bimobject.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bimobject.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bimobject.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,18 +1,23 @@
<?php
-class BimObject {
-
- public function transformObjectToArray() {
- $reflection = new ReflectionObject($this);
- $publicMethods =
$reflection->getMethods(ReflectionProperty::IS_PUBLIC);
- $result = array();
- foreach($publicMethods as $method) {
- /* @var $method ReflectionMethod */
- if(preg_match("/^get(.+)/", $method->getName(),
$matches)) {
- $memberVarible = lcfirst($matches[1]);
- $value = $method->invoke($this);
- $result[$memberVarible] = $value;
+
+ class BimObject
+ {
+
+ public function transformObjectToArray()
+ {
+ $reflection = new ReflectionObject($this);
+ $publicMethods =
$reflection->getMethods(ReflectionProperty::IS_PUBLIC);
+ $result = array();
+ foreach($publicMethods as $method)
+ {
+ /* @var $method ReflectionMethod */
+ if(preg_match("/^get(.+)/", $method->getName(),
$matches))
+ {
+ $memberVarible = lcfirst($matches[1]);
+ $value = $method->invoke($this);
+ $result[$memberVarible] = $value;
+ }
}
+ return $result;
}
- return $result;
- }
-}
\ No newline at end of file
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.boattribute.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.boattribute.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.boattribute.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,125 +1,123 @@
<?php
- /**
- * FIXME: Description
- *
- * @author Espen
- */
- class bim_boattribute
- {
- private $id, $name, $display_name, $value, $data_type, $unit, $desc;
+ /**
+ * FIXME: Description
+ *
+ * @author Espen
+ */
+ class bim_boattribute
+ {
- /**
- * Constructor. Takes an optional array of values where the keys should
- * be identical to the name of the variable it is trying to set. Setter
- * methods reflect these names.
- *
- * @param array $values
- */
- public function __construct($properties = null)
- {
- if($this->valid_properties($properties))
- {
- $this->set_id($properties['id']); // May be null
- $this->set_name($properties['name']);
- $this->set_display_name($properties['display_name']);
- $this->set_value($properties['value']);
- $this->set_data_type($properties['data_type']);
- $this->set_unit($properties['unit']);
- $this->set_desc($properties['desc']);
- }
- }
+ private $id, $name, $display_name, $value, $data_type, $unit,
$desc;
- /**
- * Simple value array validation.
- *
- * @param array $properties
- * @return boolean
- */
- private function valid_properties(array $properties) {
- if(!is_array($properties) || empty($properties['name']) ||
empty($properties['display_name']) || empty($properties['value']) ||
empty($properties['data_type']) || empty($properties['unit']))
- {
- return false;
- }
- return true;
- }
+ /**
+ * Constructor. Takes an optional array of values where the
keys should
+ * be identical to the name of the variable it is trying to
set. Setter
+ * methods reflect these names.
+ *
+ * @param array $values
+ */
+ public function __construct($properties = null)
+ {
+ if($this->valid_properties($properties))
+ {
+ $this->set_id($properties['id']); // May be null
+ $this->set_name($properties['name']);
+
$this->set_display_name($properties['display_name']);
+ $this->set_value($properties['value']);
+ $this->set_data_type($properties['data_type']);
+ $this->set_unit($properties['unit']);
+ $this->set_desc($properties['desc']);
+ }
+ }
+ /**
+ * Simple value array validation.
+ *
+ * @param array $properties
+ * @return boolean
+ */
+ private function valid_properties(array $properties)
+ {
+ if(!is_array($properties) || empty($properties['name'])
|| empty($properties['display_name']) || empty($properties['value']) ||
empty($properties['data_type']) || empty($properties['unit']))
+ {
+ return false;
+ }
+ return true;
+ }
+ public function get_id()
+ {
+ return $this->id;
+ }
- public function get_id()
- {
- return $this->id;
- }
+ public function set_id($id)
+ {
+ $this->id = $id;
+ }
- public function set_id($id)
- {
- $this->id = $id;
- }
+ public function get_name()
+ {
+ return $this->name;
+ }
- public function get_name()
- {
- return $this->name;
- }
+ public function set_name($name)
+ {
+ $this->name = $name;
+ }
- public function set_name($name)
- {
- $this->name = $name;
- }
+ public function get_display_name()
+ {
+ return $this->display_name;
+ }
- public function get_display_name()
- {
- return $this->display_name;
- }
+ public function set_display_name($display_name)
+ {
+ $this->display_name = $display_name;
+ }
- public function set_display_name($display_name)
- {
- $this->display_name = $display_name;
- }
+ public function get_value()
+ {
+ return $this->value;
+ }
- public function get_value()
- {
- return $this->value;
- }
+ public function set_value($value)
+ {
+ $this->value = $value;
+ }
- public function set_value($value)
- {
- $this->value = $value;
- }
+ public function get_data_type()
+ {
+ return $this->data_type;
+ }
- public function get_data_type()
- {
- return $this->data_type;
- }
+ public function set_data_type($data_type)
+ {
+ $this->data_type = $data_type;
+ }
- public function set_data_type($data_type)
- {
- $this->data_type = $data_type;
- }
+ public function get_desc()
+ {
+ return $this->desc;
+ }
- public function get_desc()
- {
- return $this->desc;
- }
+ public function set_desc($desc)
+ {
+ $this->desc = $desc;
+ }
- public function set_desc($desc)
- {
- $this->desc = $desc;
- }
+ public function get_unit()
+ {
+ return $this->unit;
+ }
- public function get_unit()
- {
- return $this->unit;
- }
+ public function set_unit($unit)
+ {
+ $this->unit = $unit;
+ }
- public function set_unit($unit)
- {
- $this->unit = $unit;
- }
-
-
-
- public function __toString()
- {
- return $this->display_name + ": " + $this->value + " " +
$this->unit;
- }
- }
+ public function __toString()
+ {
+ return $this->display_name + ": " + $this->value + " "
+ $this->unit;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.boattribute_owner.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.boattribute_owner.inc.php
2016-01-05 08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.boattribute_owner.inc.php
2016-01-05 08:48:25 UTC (rev 14621)
@@ -1,66 +1,64 @@
<?php
- /**
- * Description of classboattrobjectinc
- *
- * @author Espen
- * @abstract
- */
- abstract class bim_boattribute_owner
- {
- protected $attributes;
- /**
- * Set the value-object of a given attribute.
- * If used on a group the attribute will be added if not already
existing
- * and (default) value will be set.
- *
- * If used on an item it will override the value set by the group.
- * Attributes not already set on the group, however, cannot be set on
- * an item and will return false.
- *
- * @abstract
- * @param string $attr_def
- * @param bim_boattribute $attr
- * @return bool FALSE if failed, TRUE otherwise.
- */
- public abstract function set_attribute($attr_def, bim_boattribute
$attr);
+ /**
+ * Description of classboattrobjectinc
+ *
+ * @author Espen
+ * @abstract
+ */
+ abstract class bim_boattribute_owner
+ {
+ protected $attributes;
- /**
- * Get the value of a given attribute.
- *
- * @param string $attr_def
- * @return mixed The value.
- */
- public function get_attribute($attr_def)
- {
- return ($this->attributes[$attr_def] instanceof bim_boattribute ?
$this->attributes[$attr_def] : null);
- }
+ /**
+ * Set the value-object of a given attribute.
+ * If used on a group the attribute will be added if not
already existing
+ * and (default) value will be set.
+ *
+ * If used on an item it will override the value set by the
group.
+ * Attributes not already set on the group, however, cannot be
set on
+ * an item and will return false.
+ *
+ * @abstract
+ * @param string $attr_def
+ * @param bim_boattribute $attr
+ * @return bool FALSE if failed, TRUE otherwise.
+ */
+ public abstract function set_attribute($attr_def,
bim_boattribute $attr);
+ /**
+ * Get the value of a given attribute.
+ *
+ * @param string $attr_def
+ * @return mixed The value.
+ */
+ public function get_attribute($attr_def)
+ {
+ return ($this->attributes[$attr_def] instanceof
bim_boattribute ? $this->attributes[$attr_def] : null);
+ }
- /**
- * Fetches a list of attributes (without values) on this object.
- *
- * @return array
- */
- public function get_attribute_list()
- {
- return $this->attributes;
- }
+ /**
+ * Fetches a list of attributes (without values) on this object.
+ *
+ * @return array
+ */
+ public function get_attribute_list()
+ {
+ return $this->attributes;
+ }
-
- /**
- * Removes an attribute and its value from the object.
- *
- * If used on a group the attribute will be removed completely on the
- * group and items belonging to it.
- *
- * If used on an item it will only be removed from the item, which will
- * then inherit the attribute from the group it belongs to.
- *
- * @abstract
- * @param string $attr_def
- */
- public abstract function remove_attribute($attr_def);
- }
-
+ /**
+ * Removes an attribute and its value from the object.
+ *
+ * If used on a group the attribute will be removed completely
on the
+ * group and items belonging to it.
+ *
+ * If used on an item it will only be removed from the item,
which will
+ * then inherit the attribute from the group it belongs to.
+ *
+ * @abstract
+ * @param string $attr_def
+ */
+ public abstract function remove_attribute($attr_def);
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bobimitem.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bobimitem.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bobimitem.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,82 +1,108 @@
<?php
+ phpgw::import_class('bim.bimmodelinformation');
- phpgw::import_class('bim.bimmodelinformation');
-
- interface bobimitem {
- public function setIfcXml(SimpleXMLElement $xml);
+ interface bobimitem
+ {
+
+ public function setIfcXml(SimpleXMLElement $xml);
+
public function setSobimitem(sobimitem $sobimitem);
+
public function setSobimtype(sobimtype $sobimtype);
- public function setSobimmodelinformation(sobimmodelinformation
$sobimmodelinformation);
+
+ public function setSobimmodelinformation(sobimmodelinformation
$sobimmodelinformation);
+
public function loadIfcItemsIntoDatabase();
+
public function fetchItemsByModelId();
}
-
- class bobimitem_impl implements bobimitem {
+
+ class bobimitem_impl implements bobimitem
+ {
+
private $ifcXml;
/* @var $sobimitem sobimitem */
private $sobimitem;
private $sobimtype;
private $sobimmodelinformation;
-
- public function __construct() {
+
+ public function __construct()
+ {
}
-
- public function loadIfcItemsIntoDatabase() {
+
+ public function loadIfcItemsIntoDatabase()
+ {
$this->checkArguments();
/* @var $modelInfo SimpleXMLElement */
$modelInfo = $this->ifcXml->modelInformation[0];
- $modelInfoXml = $modelInfo->asXML();
+ $modelInfoXml = $modelInfo->asXML();
$bimmodelInformation = new BimModelInformation();
$bimmodelInformation->loadVariablesFromXml($modelInfo);
$this->sobimmodelinformation->setBimModelInformation($bimmodelInformation);
- try {
+ try
+ {
$this->sobimmodelinformation->updateModelInformation();
- } catch (Exception $e) {
+ }
+ catch(Exception $e)
+ {
throw $e;
}
//var_dump($this->ifcXml);
-
+
$BimItems = $this->loopThrough();
-
- foreach($BimItems as $item) {
+
+ foreach($BimItems as $item)
+ {
$type = $item->getType();
- try {
+ try
+ {
$this->sobimtype->addBimObjectType($type);
- } catch (Exception $e) {
+ }
+ catch(Exception $e)
+ {
// do nothing
}
- try {
+ try
+ {
$this->sobimitem->addBimItem($item);
- } catch (BimDataException $e) {
- throw new BimDataException("Data
exception\n MSG:".$e->getMessage()."\nReason:".$e->getPrevious()->getMessage(),
$e);
+ }
+ catch(BimDataException $e)
+ {
+ throw new BimDataException("Data
exception\n MSG:" . $e->getMessage() . "\nReason:" .
$e->getPrevious()->getMessage(), $e);
//echo "Data exception with
message:".$e->getMessage()."\n";
//echo
"Reason:".$e->getPrevious()->getMessage();
//break;
}
}
-
}
-
- private function loopThrough() {
+
+ private function loopThrough()
+ {
$BimItemArray = array();
/* @var $second_gen SimpleXMLElement */
- foreach ($this->ifcXml->children() as $second_gen) {
+ foreach($this->ifcXml->children() as $second_gen)
+ {
//echo "Child with
name:".$second_gen->getName()."\n";
- if ( $second_gen['ifcObjectType']) {
+ if($second_gen['ifcObjectType'])
+ {
$bimItem =
$this->createBimItem($second_gen);
array_push($BimItemArray, $bimItem);
-
- } else if($second_gen->getName() !=
"modelInformation") {
+ }
+ else if($second_gen->getName() !=
"modelInformation")
+ {
/* @var $third_gen SimpleXMLElement */
- foreach ($second_gen->children() as
$third_gen) {
- if (
$third_gen['ifcObjectType']) {
+ foreach($second_gen->children() as
$third_gen)
+ {
+ if($third_gen['ifcObjectType'])
+ {
$bimItem =
$this->createBimItem($third_gen);
array_push($BimItemArray, $bimItem);
-
- } else {
- echo "Could not add
item, missing attribute, item:".$third_gen->asXML();
}
+ else
+ {
+ echo "Could not add
item, missing attribute, item:" . $third_gen->asXML();
+ }
}
}
}
@@ -87,51 +113,69 @@
* sobimitem (with modelId set)
*
*/
- public function fetchItemsByModelId() {
+
+ public function fetchItemsByModelId()
+ {
$this->checkFetchArguments();
return $this->sobimitem->retrieveItemsByModelId();
}
/*
* @throws IncompleteItemException if the ifc object is missing
anything
*/
- private function createBimItem(& $ifcObject) {
+
+ private function createBimItem(& $ifcObject)
+ {
$guid = $ifcObject->attributes->guid;
$type = $ifcObject['ifcObjectType'];
$xml = $ifcObject->asXML();
- if(empty($guid) || empty($type) || empty($xml)) {
- $currentItem = "GUID:".$guid."\n".
-
"Type:".$type."\n".
- "XML:".$xml;
+ if(empty($guid) || empty($type) || empty($xml))
+ {
+ $currentItem = "GUID:" . $guid . "\n" .
+ "Type:" . $type . "\n" .
+ "XML:" . $xml;
throw new IncompleteItemException($currentItem);
}
- // return new BimItem(null, $guid, $type, $xml,
$this->sobimitem->getModelId());
+ // return new BimItem(null, $guid, $type, $xml,
$this->sobimitem->getModelId());
return new BimItem(null, $guid, $type, $xml,
$this->sobimmodelinformation->getModelId());// Sigurd 15.feb 2011: this one
seems to work
}
-
- private function checkFetchArguments() {
- if(!$this->sobimitem) {
+
+ private function checkFetchArguments()
+ {
+ if(!$this->sobimitem)
+ {
throw new InvalidArgumentException("Missing
sobimitem");
}
}
- private function checkArguments() {
- if(empty($this->ifcXml) || empty($this->sobimitem) ||
empty($this->sobimtype) || empty($this->sobimmodelinformation)) {
- $args = "IfcXml
type:".gettype($this->ifcXml)."\n".
- "Sobimitem
type:".gettype($this->sobimitem)."\n".
- "Sobimtype
type:".gettype($this->sobimtype)."\n".
- "Sobimmodelinformation
type:".gettype($this->sobimmodelinformation)."\n";
- throw new
InvalidArgumentException("BObimitem:Incorrect arguments\b".$args);
+
+ private function checkArguments()
+ {
+ if(empty($this->ifcXml) || empty($this->sobimitem) ||
empty($this->sobimtype) || empty($this->sobimmodelinformation))
+ {
+ $args = "IfcXml type:" . gettype($this->ifcXml)
. "\n" .
+ "Sobimitem type:" . gettype($this->sobimitem) .
"\n" .
+ "Sobimtype type:" . gettype($this->sobimtype) .
"\n" .
+ "Sobimmodelinformation type:" .
gettype($this->sobimmodelinformation) . "\n";
+ throw new
InvalidArgumentException("BObimitem:Incorrect arguments\b" . $args);
}
}
- public function setSobimmodelinformation(sobimmodelinformation
$sobimmodelinformation) {
+
+ public function setSobimmodelinformation(sobimmodelinformation
$sobimmodelinformation)
+ {
$this->sobimmodelinformation = $sobimmodelinformation;
}
- public function setIfcXml(SimpleXMLElement $xml) {
+
+ public function setIfcXml(SimpleXMLElement $xml)
+ {
$this->ifcXml = $xml;
}
- public function setSobimitem(sobimitem $sobimitem) {
+
+ public function setSobimitem(sobimitem $sobimitem)
+ {
$this->sobimitem = $sobimitem;
}
- public function setSobimtype(sobimtype $sobimType){
+
+ public function setSobimtype(sobimtype $sobimType)
+ {
$this->sobimtype = $sobimType;
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bobimmodel.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bobimmodel.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bobimmodel.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,228 +1,302 @@
<?php
-/*
- * Business logic class for creating new BIM models in Portico
- * This class is designed with dependancy injection in mind
- */
-/*phpgw::import_class('bim.bimExceptions');
-phpgw::import_class('bim.sobim');
-phpgw::import_class('bim.sobimmodel');
-phpgw::import_class('bim.sovfs');*/
-interface bobimmodel {
- public function addUploadedIfcModel();
- public function createBimModelList();
- public function setVfsObject(sovfs $vfs);
- public function setSobimmodel(sobimmodel $sobimmodel);
- public function checkBimModelExists();
- public function checkBimModelExistsByModelId();
- public function checkBimModelIsUsed();
- public function removeIfcModel();
- public function removeIfcModelByModelId();
- public function setModelName($name);
- public function getModelName();
- public function getIfcFileNameWithRealPath();
-}
+ /*
+ * Business logic class for creating new BIM models in Portico
+ * This class is designed with dependancy injection in mind
+ */
+ /* phpgw::import_class('bim.bimExceptions');
+ phpgw::import_class('bim.sobim');
+ phpgw::import_class('bim.sobimmodel');
+ phpgw::import_class('bim.sovfs'); */
-class bobimmodel_impl implements bobimmodel {
- private $sovfs;
- private $sobimmodel;
- private $modelName;
- function __construct() {
-
+ interface bobimmodel
+ {
+
+ public function addUploadedIfcModel();
+
+ public function createBimModelList();
+
+ public function setVfsObject(sovfs $vfs);
+
+ public function setSobimmodel(sobimmodel $sobimmodel);
+
+ public function checkBimModelExists();
+
+ public function checkBimModelExistsByModelId();
+
+ public function checkBimModelIsUsed();
+
+ public function removeIfcModel();
+
+ public function removeIfcModelByModelId();
+
+ public function setModelName($name);
+
+ public function getModelName();
+
+ public function getIfcFileNameWithRealPath();
}
-
- public function setVfsObject(sovfs $vfs) {
- $this->sovfs = $vfs;
- }
- public function setSobimmodel(sobimmodel $sobimmodel) {
- $this->sobimmodel = $sobimmodel;
- }
- /*
- * taken from calss.uitts.inc.php
- * @return boolean true if success
- * @throws FileExistsException if filename is already used
- * @throws CopyFailureException if there is a failure copying
- */
-
- public function addUploadedIfcModel() {
- if(!$this->sovfs) {
- throw new Exception('Missing vfs object!');
+
+ class bobimmodel_impl implements bobimmodel
+ {
+
+ private $sovfs;
+ private $sobimmodel;
+ private $modelName;
+
+ function __construct()
+ {
+
}
- try {
- $filename = $this->saveUploadedBimData();
- $this->applyModelName($filename);
- $file_database_id = $this->sovfs->retrieveVfsFileId();
- $this->sobimmodel->setVfsdatabaseid($file_database_id);
- $this->sobimmodel->setModelName($this->modelName);
- $this->sobimmodel->addBimModel();
- return true;
- } catch (FileExistsException $e) {
- throw $e;
- } catch (CopyFailureException $e) {
- throw $e;
- } catch ( ModelExistsException $e) {
- throw $e;
- }catch (Exception $e) {
- throw $e;
+
+ public function setVfsObject(sovfs $vfs)
+ {
+ $this->sovfs = $vfs;
}
- }
-
- private function applyModelName($filename) {
- if(!($this->modelName && strlen($this->modelName)>0)) {
- $this->modelName = $filename;
- }
- }
- /*
- * requires sobimmodel with db set
- */
- public function createBimModelList() {
- if(!$this->sobimmodel) {
- throw new Exception('Missing sobimodel object!');
+
+ public function setSobimmodel(sobimmodel $sobimmodel)
+ {
+ $this->sobimmodel = $sobimmodel;
}
- $BimModelArray = $this->sobimmodel->retrieveBimModelList();
- if(!$BimModelArray) {
- return null;
- } else {
- $outputArray = array();
-
- foreach($BimModelArray as $BimModel) {
- //var_dump($BimModel);
- /* @var $BimModel BimModel */
- //array_push($outputArray,
$this->transformObjectToArray($BimModel));
- array_push($outputArray,
$BimModel->transformObjectToArray());
+ /*
+ * taken from calss.uitts.inc.php
+ * @return boolean true if success
+ * @throws FileExistsException if filename is already used
+ * @throws CopyFailureException if there is a failure copying
+ */
+
+ public function addUploadedIfcModel()
+ {
+ if(!$this->sovfs)
+ {
+ throw new Exception('Missing vfs object!');
}
- return $outputArray;
+ try
+ {
+ $filename = $this->saveUploadedBimData();
+ $this->applyModelName($filename);
+ $file_database_id =
$this->sovfs->retrieveVfsFileId();
+
$this->sobimmodel->setVfsdatabaseid($file_database_id);
+
$this->sobimmodel->setModelName($this->modelName);
+ $this->sobimmodel->addBimModel();
+ return true;
+ }
+ catch(FileExistsException $e)
+ {
+ throw $e;
+ }
+ catch(CopyFailureException $e)
+ {
+ throw $e;
+ }
+ catch(ModelExistsException $e)
+ {
+ throw $e;
+ }
+ catch(Exception $e)
+ {
+ throw $e;
+ }
}
-
- }
-
-
- /*
- * This function requires:
- * An SOvfs object with the filename and the submodule set
- * An sobimmodel object with the modelname and the vfs_database_id
- */
- public function checkBimModelExists() {
- if(!$this->sobimmodel || !$this->sovfs) {
- throw new
InvalidArgumentException($this->displayArguments());
+
+ private function applyModelName($filename)
+ {
+ if(!($this->modelName && strlen($this->modelName) > 0))
+ {
+ $this->modelName = $filename;
+ }
}
- if($this->sovfs->checkIfFileExists()) {
- $fileId = $this->sovfs->retrieveVfsFileId();
- $this->sobimmodel->setVfsdatabaseid($fileId);
- if($this->sobimmodel->checkIfModelExists() ) {
- return true;
+ /*
+ * requires sobimmodel with db set
+ */
+
+ public function createBimModelList()
+ {
+ if(!$this->sobimmodel)
+ {
+ throw new Exception('Missing sobimodel
object!');
}
-
- }
- return false;
-
- }
- public function getIfcFileNameWithRealPath() {
- $this->checkIdVfsArguments();
- /* @var $bimModel BimModel */
- $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
- $this->sovfs->setFilename($bimModel->getFileName());
- return $this->sovfs->getAbsolutePathOfVfsFile();
- }
- /*
- * needs sobimmodel object with db and modelId set
- * @return boolean
- */
- public function checkBimModelExistsByModelId() {
- $this->checkIdArguments();
- $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
- return ($bimModel != null);
- }
- public function checkBimModelIsUsed() {
- $this->checkIdArguments();
- /* @var $bimModel BimModel */
- $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
- return ($bimModel->getUsedItemCount() > 0);
- }
-
- private function displayArguments() {
- $string = "(bobimmodel)Argument list:\n".
- "Model name:\t $this->modelName \n".
- "Model id:\t
".$this->sobimmodel->getModelId()." \n".
- "SOvfs:\t ".gettype($this->sovfs)."\n".
- "SObimmodel:\t
".gettype($this->sobimmodel)."\n".
- "Submodule:\t
".$this->sovfs->getSubModule()."\n";
- return $string;
-
- }
- /*
- * This function needs:
- * An SOvfs object with the filename and the submodule set
- * An sobimmodel object with the modelname and the vfs_database_id
- */
- public function removeIfcModel() {
- if(!$this->sobimmodel || !$this->sovfs) {
- throw new
InvalidArgumentException($this->displayArguments());
+ $BimModelArray =
$this->sobimmodel->retrieveBimModelList();
+ if(!$BimModelArray)
+ {
+ return null;
+ }
+ else
+ {
+ $outputArray = array();
+
+ foreach($BimModelArray as $BimModel)
+ {
+ //var_dump($BimModel);
+ /* @var $BimModel BimModel */
+ //array_push($outputArray,
$this->transformObjectToArray($BimModel));
+ array_push($outputArray,
$BimModel->transformObjectToArray());
+ }
+ return $outputArray;
+ }
}
- $this->sobimmodel->removeBimModelFromDatabase();
- $this->sovfs->removeFileFromVfs();
- return true;
- }
- /*
- * needs sobimmodel object with db and modelId set
- * needs sovfs object, with submodule set
- * @throws ModelDoesNotExistException
- */
- public function removeIfcModelByModelId() {
- try {
+ /*
+ * This function requires:
+ * An SOvfs object with the filename and the submodule set
+ * An sobimmodel object with the modelname and the
vfs_database_id
+ */
+
+ public function checkBimModelExists()
+ {
+ if(!$this->sobimmodel || !$this->sovfs)
+ {
+ throw new
InvalidArgumentException($this->displayArguments());
+ }
+ if($this->sovfs->checkIfFileExists())
+ {
+ $fileId = $this->sovfs->retrieveVfsFileId();
+ $this->sobimmodel->setVfsdatabaseid($fileId);
+ if($this->sobimmodel->checkIfModelExists())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function getIfcFileNameWithRealPath()
+ {
$this->checkIdVfsArguments();
- } catch (InvalidArgumentException $e) {
- throw $e;
- }
- /* @var $bimModel BimModel */
- try {
+ /* @var $bimModel BimModel */
$bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
- $this->sobimmodel->setModelName($bimModel->getName());
-
$this->sobimmodel->setVfsdatabaseid($bimModel->getVfsFileId());
-
$this->sovfs->setFilename($bimModel->getFileName());
- $this->removeIfcModel();
- } catch (ModelDoesNotExistException $e) {
- throw new ModelDoesNotExistException();
+ return $this->sovfs->getAbsolutePathOfVfsFile();
}
-
- }
-
- private function checkIdVfsArguments() {
- if(!$this->sobimmodel || !$this->sovfs ||
!$this->sobimmodel->getModelId() || !$this->sovfs->getSubModule()) {
- throw new
InvalidArgumentException($this->displayArguments());
+ /*
+ * needs sobimmodel object with db and modelId set
+ * @return boolean
+ */
+
+ public function checkBimModelExistsByModelId()
+ {
+ $this->checkIdArguments();
+ $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
+ return ($bimModel != null);
}
- }
- private function checkIdArguments() {
- if(!$this->sobimmodel || !$this->sobimmodel->getModelId() ||
!$this->sovfs->getSubModule()) {
- throw new
InvalidArgumentException($this->displayArguments());
+
+ public function checkBimModelIsUsed()
+ {
+ $this->checkIdArguments();
+ /* @var $bimModel BimModel */
+ $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
+ return ($bimModel->getUsedItemCount() > 0);
}
- }
- /*
- * expects item from the $_FILES object in the form:
- * @param $uploadedFileArray Array ( [name] => <name>
- * [type] => <mimeType>
- * [tmp_name] => <filename with path>
- * [error] => <error status>
- * [size] => <file size> )
- * @throws FileExistsException|Exception
- * @return String|null filename of the uploaded file
- */
- private function saveUploadedBimData() {
- try {
- return $this->sovfs->addFileToVfs();
- } catch (FileExistsException $e) {
- throw $e;
- } catch (CopyFailureException $e) {
- throw $e;
- } catch (Exception $e) {
- throw $e;
+
+ private function displayArguments()
+ {
+ $string = "(bobimmodel)Argument list:\n" .
+ "Model name:\t $this->modelName \n" .
+ "Model id:\t " . $this->sobimmodel->getModelId() . "
\n" .
+ "SOvfs:\t " . gettype($this->sovfs) . "\n" .
+ "SObimmodel:\t " . gettype($this->sobimmodel) . "\n" .
+ "Submodule:\t " . $this->sovfs->getSubModule() . "\n";
+ return $string;
}
- }
-
- public function setModelName($name) {
- $this->modelName = $name;
- }
- public function getModelName() {
- return $this->modelName;
- }
-}
+ /*
+ * This function needs:
+ * An SOvfs object with the filename and the submodule set
+ * An sobimmodel object with the modelname and the
vfs_database_id
+ */
+
+ public function removeIfcModel()
+ {
+ if(!$this->sobimmodel || !$this->sovfs)
+ {
+ throw new
InvalidArgumentException($this->displayArguments());
+ }
+ $this->sobimmodel->removeBimModelFromDatabase();
+ $this->sovfs->removeFileFromVfs();
+ return true;
+ }
+ /*
+ * needs sobimmodel object with db and modelId set
+ * needs sovfs object, with submodule set
+ * @throws ModelDoesNotExistException
+ */
+
+ public function removeIfcModelByModelId()
+ {
+ try
+ {
+ $this->checkIdVfsArguments();
+ }
+ catch(InvalidArgumentException $e)
+ {
+ throw $e;
+ }
+ /* @var $bimModel BimModel */
+ try
+ {
+ $bimModel =
$this->sobimmodel->retrieveBimModelInformationById();
+
$this->sobimmodel->setModelName($bimModel->getName());
+
$this->sobimmodel->setVfsdatabaseid($bimModel->getVfsFileId());
+
+
$this->sovfs->setFilename($bimModel->getFileName());
+ $this->removeIfcModel();
+ }
+ catch(ModelDoesNotExistException $e)
+ {
+ throw new ModelDoesNotExistException();
+ }
+ }
+
+ private function checkIdVfsArguments()
+ {
+ if(!$this->sobimmodel || !$this->sovfs ||
!$this->sobimmodel->getModelId() || !$this->sovfs->getSubModule())
+ {
+ throw new
InvalidArgumentException($this->displayArguments());
+ }
+ }
+
+ private function checkIdArguments()
+ {
+ if(!$this->sobimmodel ||
!$this->sobimmodel->getModelId() || !$this->sovfs->getSubModule())
+ {
+ throw new
InvalidArgumentException($this->displayArguments());
+ }
+ }
+ /*
+ * expects item from the $_FILES object in the form:
+ * @param $uploadedFileArray Array ( [name] => <name>
+ * [type] => <mimeType>
+ * [tmp_name] => <filename with path>
+ * [error] => <error status>
+ * [size] => <file size> )
+ * @throws FileExistsException|Exception
+ * @return String|null filename of the uploaded file
+ */
+
+ private function saveUploadedBimData()
+ {
+ try
+ {
+ return $this->sovfs->addFileToVfs();
+ }
+ catch(FileExistsException $e)
+ {
+ throw $e;
+ }
+ catch(CopyFailureException $e)
+ {
+ throw $e;
+ }
+ catch(Exception $e)
+ {
+ throw $e;
+ }
+ }
+
+ public function setModelName($name)
+ {
+ $this->modelName = $name;
+ }
+
+ public function getModelName()
+ {
+ return $this->modelName;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.bogroup.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.bogroup.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.bogroup.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,66 +1,67 @@
<?php
- /**
- * Description of classbogroupinc
- *
- * @author Espen
- */
- class bim_bogroup extends bim_boattribute_owner
- {
- private $id, $name, $bpn, $nat_group_no, $catalog;
+ /**
+ * Description of classbogroupinc
+ *
+ * @author Espen
+ */
+ class bim_bogroup extends bim_boattribute_owner
+ {
- public function __construct()
- {
+ private $id, $name, $bpn, $nat_group_no, $catalog;
- }
+ public function __construct()
+ {
- public function get_id() {
- return $this->id;
- }
+ }
- public function set_id($id) {
- $this->id = $id;
- }
-
- public function get_name()
- {
- return $this->name;
- }
+ public function get_id()
+ {
+ return $this->id;
+ }
- public function set_name($name)
- {
- $this->name = $name;
- }
+ public function set_id($id)
+ {
+ $this->id = $id;
+ }
- public function get_bpn()
- {
- return $this->bpn;
- }
+ public function get_name()
+ {
+ return $this->name;
+ }
- public function set_bpn($bpn)
- {
- $this->bpn = $bpn;
- }
+ public function set_name($name)
+ {
+ $this->name = $name;
+ }
- public function get_nat_group_no()
- {
- return $this->nat_group_no;
- }
+ public function get_bpn()
+ {
+ return $this->bpn;
+ }
- public function set_nat_group_no($nat_group_no)
- {
- $this->nat_group_no = $nat_group_no;
- }
+ public function set_bpn($bpn)
+ {
+ $this->bpn = $bpn;
+ }
- public function get_catalog()
- {
- return $this->catalog;
- }
+ public function get_nat_group_no()
+ {
+ return $this->nat_group_no;
+ }
- public function set_catalog(bim_bocatalog $catalog)
- {
- $this->catalog = $catalot;
- }
+ public function set_nat_group_no($nat_group_no)
+ {
+ $this->nat_group_no = $nat_group_no;
+ }
+ public function get_catalog()
+ {
+ return $this->catalog;
+ }
- }
+ public function set_catalog(bim_bocatalog $catalog)
+ {
+ $this->catalog = $catalot;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.boitem.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.boitem.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.boitem.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,91 +1,95 @@
<?php
+ include_class('bim', 'boattribute_owner', 'inc/');
-include_class('bim', 'boattribute_owner', 'inc/');
+ /**
+ * FIXME: Description
+ *
+ * @author Espen
+ */
+ class bim_boitem extends bim_boattribute_owner
+ {
- /**
- * FIXME: Description
- *
- * @author Espen
- */
- class bim_boitem extends bim_boattribute_owner
- {
- private $id, $installed_date, $location_id, $vendor_id;
+ private $id, $installed_date, $location_id, $vendor_id;
- /**
- * Should contain the group object of which this item belongs to.
- * @var bim_bogroup
- */
- private $group;
+ /**
+ * Should contain the group object of which this item belongs
to.
+ * @var bim_bogroup
+ */
+ private $group;
- public function __construct($id = null, $installed_date = null,
$location_id = null, $vendor_id = null)
- {
- $this->set_installed_date($installed_date);
- $this->set_id($id);
- $this->set_location_id($location_id);
- $this->set_vendor_id($location_id);
- }
+ public function __construct($id = null, $installed_date = null,
$location_id = null, $vendor_id = null)
+ {
+ $this->set_installed_date($installed_date);
+ $this->set_id($id);
+ $this->set_location_id($location_id);
+ $this->set_vendor_id($location_id);
+ }
-
- public function remove_attribute($attr_def) {
- $this->attributes[$attr_def] = null;
- }
+ public function remove_attribute($attr_def)
+ {
+ $this->attributes[$attr_def] = null;
+ }
- public function set_attribute($attr_def, bim_boattribute $attr) {
- $group_attrs = $this->group->get_attribute_list();
- if(array_key_exists($attr_def, $group_attrs))
- {
- $this->attributes[$attr_def] = $attr;
- return true;
- }
-
- // Return false if array key (the attr definition) doesn't exist
in group.
- return false;
- }
+ public function set_attribute($attr_def, bim_boattribute $attr)
+ {
+ $group_attrs = $this->group->get_attribute_list();
+ if(array_key_exists($attr_def, $group_attrs))
+ {
+ $this->attributes[$attr_def] = $attr;
+ return true;
+ }
+ // Return false if array key (the attr definition)
doesn't exist in group.
+ return false;
+ }
- public function set_installed_date($installed_date)
- {
- $this->installed_date = $installed_date;
- }
+ public function set_installed_date($installed_date)
+ {
+ $this->installed_date = $installed_date;
+ }
- public function get_installed_date()
- {
- return (int) $this->installed_date;
- }
+ public function get_installed_date()
+ {
+ return (int)$this->installed_date;
+ }
- public function get_id() {
- return $this->id;
- }
+ public function get_id()
+ {
+ return $this->id;
+ }
- public function set_id($id) {
- $this->id = $id;
- }
+ public function set_id($id)
+ {
+ $this->id = $id;
+ }
- public function set_group(bim_bogroup $group)
- {
- $this->group = $group;
- }
+ public function set_group(bim_bogroup $group)
+ {
+ $this->group = $group;
+ }
- public function get_group()
- {
- return $this->group;
- }
-
- public function get_location_id() {
- return $this->location_id;
- }
+ public function get_group()
+ {
+ return $this->group;
+ }
- public function set_location_id($location_id) {
- $this->location_id = $location_id;
- }
+ public function get_location_id()
+ {
+ return $this->location_id;
+ }
- public function get_vendor_id() {
- return $this->vendor_id;
- }
+ public function set_location_id($location_id)
+ {
+ $this->location_id = $location_id;
+ }
- public function set_vendor_id($vendor_id) {
- $this->vendor_id = $vendor_id;
- }
+ public function get_vendor_id()
+ {
+ return $this->vendor_id;
+ }
-
- }
+ public function set_vendor_id($vendor_id)
+ {
+ $this->vendor_id = $vendor_id;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.menu.inc.php 2016-01-05 08:28:44 UTC
(rev 14620)
+++ branches/dev-syncromind/bim/inc/class.menu.inc.php 2016-01-05 08:48:25 UTC
(rev 14621)
@@ -8,23 +8,21 @@
* @package bim
* @version $Id$
*/
-
/*
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
/**
* Menus
*
@@ -32,6 +30,7 @@
*/
class bim_menu
{
+
/**
* Get the menus for the bim
*
@@ -45,122 +44,126 @@
$menus = array();
$menus['navbar'] = array
- (
+ (
'bim' => array
- (
- 'text' => lang('bim'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
"bim.uibim.showModels") ),
- 'image' => array('bim', 'navbar'),
- 'order' => 35,
- 'group' => 'facilities management'
+ (
+ 'text' => lang('bim'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
"bim.uibim.showModels")),
+ 'image' => array('bim', 'navbar'),
+ 'order' => 35,
+ 'group' => 'facilities management'
),
);
$menus['toolbar'] = array();
- if ( $GLOBALS['phpgw']->acl->check('run',
phpgwapi_acl::READ, 'admin')
+ if($GLOBALS['phpgw']->acl->check('run',
phpgwapi_acl::READ, 'admin')
|| $GLOBALS['phpgw']->acl->check('admin',
phpgwapi_acl::ADD, 'bim'))
{
$menus['admin'] = array
- (
- 'index' => array
(
- 'text' =>
lang('Configuration'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uiconfig.index', 'appname' => 'bim') )
+ 'index' => array
+ (
+ 'text' => lang('Configuration'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uiconfig.index',
+ 'appname' => 'bim'))
),
- 'acl' => array
- (
- 'text' => lang('Configure
Access Permissions'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'preferences.uiadmin_acl.list_acl', 'acl_app' => 'bim') )
+ 'acl' => array
+ (
+ 'text' => lang('Configure
Access Permissions'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'preferences.uiadmin_acl.list_acl',
+ 'acl_app' => 'bim'))
)
);
}
- if (
isset($GLOBALS['phpgw_info']['user']['apps']['preferences']) )
+
if(isset($GLOBALS['phpgw_info']['user']['apps']['preferences']))
{
$menus['preferences'] = array
- (
+ (
array
- (
- 'text' =>
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
- 'url' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' =>
'bim', 'type'=> 'user') )
+ (
+ 'text' =>
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
+ 'url' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' =>
'bim',
+ 'type' => 'user'))
),
array
- (
- 'text' =>
$GLOBALS['phpgw']->translation->translate('Grant Access', array(), true),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiadmin.aclprefs', 'acl_app'=> 'bim'))
+ (
+ 'text' =>
$GLOBALS['phpgw']->translation->translate('Grant Access', array(), true),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiadmin.aclprefs',
+ 'acl_app' => 'bim'))
)
);
$menus['toolbar'][] = array
- (
- 'text' =>
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
- 'url' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' =>
'bim')),
- 'image' => array('bim', 'preferences')
+ (
+ 'text' =>
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
+ 'url' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' =>
'bim')),
+ 'image' => array('bim', 'preferences')
);
}
$menus['navigation'] = array();
- if ( $acl->check('.ifc', PHPGW_ACL_READ, 'bim') )
+ if($acl->check('.ifc', PHPGW_ACL_READ, 'bim'))
{
$menus['navigation']['ifc'] = array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiifc.import')),
- 'text' => lang('IFC'),
- 'image' => array('bim', 'ifc'),
- 'children' => array
(
- 'import' => array
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiifc.import')),
+ 'text' => lang('IFC'),
+ 'image' => array('bim', 'ifc'),
+ 'children' => array
(
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiifc.import')),
- 'text' =>
lang('import'),
- 'image' =>
array('bim', 'ifc_import'),
+ 'import' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiifc.import')),
+ 'text' =>
lang('import'),
+ 'image' => array('bim',
'ifc_import'),
)
)
);
}
$menus['navigation']['item'] = array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiitem.index')),
- 'text' => lang('BIM_Items'),
- 'image' => array('bim', 'custom'),
- 'children' => array_merge(array
- (
- 'index' => array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiitem.index')),
- 'text' => lang('Register')
- ),
- 'foo' => array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiitem.foo')),
- 'text' => lang('Foo')
- ),
- 'showModels' => array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'bim.uibim.showModels')),
- 'text' => lang('Show Models')
- ),
- 'ifc' => array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uiifc.import')),
- 'text' => lang('Ifc')
- ),
- 'upload' => array
- (
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'bim.uibim.upload')),
- 'text' => lang('Upload Model'),
- 'image' => array('bim', 'project_tenant_claim')
- )
- ))
- );
+ (
+ 'url' => $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'bim.uiitem.index')),
+ 'text' => lang('BIM_Items'),
+ 'image' => array('bim', 'custom'),
+ 'children' => array_merge(array
+ (
+ 'index' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiitem.index')),
+ 'text' => lang('Register')
+ ),
+ 'foo' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'bim.uiitem.foo')),
+ 'text' => lang('Foo')
+ ),
+ 'showModels' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uibim.showModels')),
+ 'text' => lang('Show Models')
+ ),
+ 'ifc' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uiifc.import')),
+ 'text' => lang('Ifc')
+ ),
+ 'upload' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'bim.uibim.upload')),
+ 'text' => lang('Upload Model'),
+ 'image' => array('bim',
'project_tenant_claim')
+ )
+ ))
+ );
$GLOBALS['phpgw_info']['flags']['currentapp'] =
$incoming_app;
return $menus;
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.restrequest.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.restrequest.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.restrequest.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,257 +1,265 @@
<?php
-class RestRequest
-{
- protected $url;
- protected $verb;
- protected $requestBody;
- protected $requestLength;
- protected $username;
- protected $password;
- protected $acceptType;
- protected $responseBody;
- protected $responseInfo;
- protected $localFile;
- protected $error = false;
- public $debug = false;
-
- public function __construct ($url = null, $verb = 'GET', $requestBody =
null, $debug = false)
+ class RestRequest
{
- $this->url = $url;
- $this->verb = $verb;
- $this->requestBody = $requestBody;
- $this->requestLength = 0;
- $this->username = null;
- $this->password = null;
- $this->acceptType = 'application/json';
- $this->responseBody = null;
- $this->responseInfo = null;
- $this->debug = $debug;
- if($this->debug) {
- echo "Request created\n".
- "URL:".$url."\n".
- "Method:".$verb."\n";
- }
- /*if ($this->requestBody !== null)
+
+ protected $url;
+ protected $verb;
+ protected $requestBody;
+ protected $requestLength;
+ protected $username;
+ protected $password;
+ protected $acceptType;
+ protected $responseBody;
+ protected $responseInfo;
+ protected $localFile;
+ protected $error = false;
+ public $debug = false;
+
+ public function __construct($url = null, $verb = 'GET',
$requestBody = null, $debug = false)
{
- $this->buildPostBody();
- }*/
- }
-
- public function flush ()
- {
- $this->requestBody = null;
- $this->requestLength = 0;
- $this->verb = 'GET';
- $this->responseBody = null;
- $this->responseInfo = null;
- }
-
- public function execute ()
- {
- $ch = curl_init();
- $this->setAuth($ch);
-
- try
+ $this->url = $url;
+ $this->verb = $verb;
+ $this->requestBody = $requestBody;
+ $this->requestLength = 0;
+ $this->username = null;
+ $this->password = null;
+ $this->acceptType = 'application/json';
+ $this->responseBody = null;
+ $this->responseInfo = null;
+ $this->debug = $debug;
+ if($this->debug)
+ {
+ echo "Request created\n" .
+ "URL:" . $url . "\n" .
+ "Method:" . $verb . "\n";
+ }
+ /* if ($this->requestBody !== null)
+ {
+ $this->buildPostBody();
+ } */
+ }
+
+ public function flush()
{
- switch (strtoupper($this->verb))
+ $this->requestBody = null;
+ $this->requestLength = 0;
+ $this->verb = 'GET';
+ $this->responseBody = null;
+ $this->responseInfo = null;
+ }
+
+ public function execute()
+ {
+ $ch = curl_init();
+ $this->setAuth($ch);
+
+ try
{
- case 'GET':
- $this->executeGet($ch);
- break;
- case 'POST':
- $this->executePost($ch);
- break;
- case 'PUT':
- $this->executePut($ch);
- break;
- case 'DELETE':
- $this->executeDelete($ch);
- break;
- default:
- throw new
InvalidArgumentException('Current verb (' . $this->verb . ') is an invalid REST
verb.');
+ switch(strtoupper($this->verb))
+ {
+ case 'GET':
+ $this->executeGet($ch);
+ break;
+ case 'POST':
+ $this->executePost($ch);
+ break;
+ case 'PUT':
+ $this->executePut($ch);
+ break;
+ case 'DELETE':
+ $this->executeDelete($ch);
+ break;
+ default:
+ throw new
InvalidArgumentException('Current verb (' . $this->verb . ') is an invalid REST
verb.');
+ }
}
+ catch(InvalidArgumentException $e)
+ {
+ curl_close($ch);
+ throw $e;
+ }
+ catch(Exception $e)
+ {
+ curl_close($ch);
+ throw $e;
+ }
}
- catch (InvalidArgumentException $e)
+
+ public function buildPostBody($data = null)
{
- curl_close($ch);
- throw $e;
+ $data = ($data !== null) ? $data : $this->requestBody;
+
+ if(!is_array($data))
+ {
+ throw new InvalidArgumentException('Invalid
data input for postBody. Array expected');
+ }
+
+ $data = http_build_query($data, '', '&');
+ $this->requestBody = $data;
}
- catch (Exception $e)
+
+ protected function executeGet($ch)
{
- curl_close($ch);
- throw $e;
+ $this->doExecute($ch);
}
-
- }
-
- public function buildPostBody ($data = null)
- {
- $data = ($data !== null) ? $data : $this->requestBody;
-
- if (!is_array($data))
+
+ protected function executePost($ch)
{
- throw new InvalidArgumentException('Invalid data input
for postBody. Array expected');
+ if(!is_string($this->requestBody))
+ {
+ //$this->buildPostBody();
+ }
+ //var_dump($this->requestBody);
+ curl_setopt($ch, CURLOPT_POST, 1); // this line MUST
COME BEFORE the CURLOPT_POSTFIELDS line !!!!
+ curl_setopt($ch, CURLOPT_POSTFIELDS,
$this->requestBody); // this automatically sets Content-Type:
multipart/form-data
+ //n.b. the input MUST be an array where one element is
of the form '<file_field>' => @/<path>/filename
+ $this->doExecute($ch);
}
-
- $data = http_build_query($data, '', '&');
- $this->requestBody = $data;
- }
-
-
-
- protected function executeGet ($ch)
- {
- $this->doExecute($ch);
- }
-
- protected function executePost ($ch)
- {
- if (!is_string($this->requestBody))
+
+ protected function executePut($ch)
{
- //$this->buildPostBody();
+ /* if (!is_string($this->requestBody))
+ {
+ $this->buildPostBody();
+ }
+
+ $this->requestLength = strlen($this->requestBody);
+
+ $fh = fopen('php://memory', 'rw');
+ fwrite($fh, $this->requestBody);
+ rewind($fh); */
+ if(!file_exists($this->localFile))
+ {
+ throw new InvalidArgumentException("Missing
file to send with put request");
+ }
+ $fp = fopen($this->localfile, "r");
+ $fileSize = filesize($fp);
+ curl_setopt($ch, CURLOPT_INFILE, $fh);
+ curl_setopt($ch, CURLOPT_INFILESIZE, $fileSize);
+ curl_setopt($ch, CURLOPT_PUT, true);
+
+ $this->doExecute($ch);
+
+ fclose($fh);
}
- //var_dump($this->requestBody);
- curl_setopt($ch, CURLOPT_POST, 1); // this line MUST COME
BEFORE the CURLOPT_POSTFIELDS line !!!!
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); //
this automatically sets Content-Type: multipart/form-data
- //n.b. the input MUST be an array where one element is of the
form '<file_field>' => @/<path>/filename
- $this->doExecute($ch);
- }
-
- protected function executePut ($ch)
- {
- /*if (!is_string($this->requestBody))
+
+ protected function executeDelete($ch)
{
- $this->buildPostBody();
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
+
+ $this->doExecute($ch);
}
-
- $this->requestLength = strlen($this->requestBody);
-
- $fh = fopen('php://memory', 'rw');
- fwrite($fh, $this->requestBody);
- rewind($fh);*/
- if( !file_exists($this->localFile)) {
- throw new InvalidArgumentException("Missing file to
send with put request");
+
+ protected function doExecute(&$curlHandle)
+ {
+ $this->setCurlOpts($curlHandle);
+ $this->responseBody = curl_exec($curlHandle);
+ $this->responseInfo = curl_getinfo($curlHandle);
+ if($this->responseInfo["http_code"] != 200)
+ {
+ $this->error = true;
+ }
+ else
+ {
+ $this->error = false;
+ }
+ curl_close($curlHandle);
}
- $fp = fopen ($this->localfile, "r");
- $fileSize = filesize($fp);
- curl_setopt($ch, CURLOPT_INFILE, $fh);
- curl_setopt($ch, CURLOPT_INFILESIZE, $fileSize);
- curl_setopt($ch, CURLOPT_PUT, true);
-
- $this->doExecute($ch);
-
- fclose($fh);
- }
-
- protected function executeDelete ($ch)
- {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
-
- $this->doExecute($ch);
- }
-
- protected function doExecute (&$curlHandle)
- {
- $this->setCurlOpts($curlHandle);
- $this->responseBody = curl_exec($curlHandle);
- $this->responseInfo = curl_getinfo($curlHandle);
- if ( $this->responseInfo["http_code"] != 200 ) {
- $this->error = true;
- } else {
- $this->error = false;
+
+ protected function setCurlOpts(&$curlHandle)
+ {
+ curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10); //
(seconds) need long timeout because of large file uploads
+ curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
+
+ curl_setopt($curlHandle, CURLOPT_URL, $this->url);
+ curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
+ $headerArray = array('Accept: ' . $this->acceptType);
+ //curl_setopt($curlHandle, CURLOPT_HTTPHEADER,
$headerArray);
+ curl_setopt($curlHandle, CURLINFO_HEADER_OUT, true);
}
- curl_close($curlHandle);
- }
-
- protected function setCurlOpts (&$curlHandle)
- {
- curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10); // (seconds)
need long timeout because of large file uploads
- curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
-
- curl_setopt($curlHandle, CURLOPT_URL, $this->url);
- curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
- $headerArray = array ('Accept: ' . $this->acceptType);
- //curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headerArray);
- curl_setopt($curlHandle, CURLINFO_HEADER_OUT, true);
- }
-
- protected function setAuth (&$curlHandle)
- {
- if ($this->username !== null && $this->password !== null)
+
+ protected function setAuth(&$curlHandle)
{
- curl_setopt($curlHandle, CURLOPT_HTTPAUTH,
CURLAUTH_DIGEST);
- curl_setopt($curlHandle, CURLOPT_USERPWD,
$this->username . ':' . $this->password);
+ if($this->username !== null && $this->password !== null)
+ {
+ curl_setopt($curlHandle, CURLOPT_HTTPAUTH,
CURLAUTH_DIGEST);
+ curl_setopt($curlHandle, CURLOPT_USERPWD,
$this->username . ':' . $this->password);
+ }
}
- }
-
- public function getAcceptType ()
- {
- return $this->acceptType;
- }
-
- public function setAcceptType ($acceptType)
- {
- $this->acceptType = $acceptType;
- }
-
- public function getPassword ()
- {
- return $this->password;
- }
-
- public function setPassword ($password)
- {
- $this->password = $password;
- }
-
- public function getResponseBody ()
- {
- return $this->responseBody;
- }
-
- public function getResponseInfo ()
- {
- return $this->responseInfo;
- }
-
- public function getUrl ()
- {
- return $this->url;
- }
-
- public function setUrl ($url)
- {
- $this->url = $url;
- }
-
- public function getUsername ()
- {
- return $this->username;
- }
-
- public function setUsername ($username)
- {
- $this->username = $username;
- }
-
- public function getVerb ()
- {
- return $this->verb;
- }
-
- public function setVerb ($verb)
- {
- $this->verb = $verb;
- }
-
- public function setLocalFile ( $filename) {
- $this->localFile = $filename;
- }
- public function getLocalFile () {
- return $this->localFile;
- }
- public function isError() {
- return $this->error;
- }
-}
+
+ public function getAcceptType()
+ {
+ return $this->acceptType;
+ }
+
+ public function setAcceptType($acceptType)
+ {
+ $this->acceptType = $acceptType;
+ }
+
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ public function setPassword($password)
+ {
+ $this->password = $password;
+ }
+
+ public function getResponseBody()
+ {
+ return $this->responseBody;
+ }
+
+ public function getResponseInfo()
+ {
+ return $this->responseInfo;
+ }
+
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+
+ public function getUsername()
+ {
+ return $this->username;
+ }
+
+ public function setUsername($username)
+ {
+ $this->username = $username;
+ }
+
+ public function getVerb()
+ {
+ return $this->verb;
+ }
+
+ public function setVerb($verb)
+ {
+ $this->verb = $verb;
+ }
+
+ public function setLocalFile($filename)
+ {
+ $this->localFile = $filename;
+ }
+
+ public function getLocalFile()
+ {
+ return $this->localFile;
+ }
+
+ public function isError()
+ {
+ return $this->error;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobim.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobim.inc.php 2016-01-05 08:28:44 UTC
(rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobim.inc.php 2016-01-05 08:48:25 UTC
(rev 14621)
@@ -2,12 +2,14 @@
//phpgw::import_class('phpgwapi.datetime'); // just a test import
-/*
- * parent SO object defining table names
- */
-interface sobim {
-
- const bimItemTable = 'fm_bim_item';
- const bimTypeTable = 'fm_bim_type';
- const bimModelTable = 'fm_bim_model';
-}
+ /*
+ * parent SO object defining table names
+ */
+ interface sobim
+ {
+
+ const bimItemTable = 'fm_bim_item';
+ const bimTypeTable = 'fm_bim_type';
+ const bimModelTable = 'fm_bim_model';
+
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobim_converter.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobim_converter.inc.php
2016-01-05 08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobim_converter.inc.php
2016-01-05 08:48:25 UTC (rev 14621)
@@ -1,95 +1,121 @@
<?php
-/*
- * Requires the following to work:
- * Curl library
- * HTTP_Request (Pear)
- */
+ /*
+ * Requires the following to work:
+ * Curl library
+ * HTTP_Request (Pear)
+ */
-phpgw::import_class('bim.restrequest');
-/*
- *
- */
-interface sobim_converter {
- public function getFacilityManagementXml();
- public function setBaseUrl($url);
-}
+ phpgw::import_class('bim.restrequest');
+ /*
+ *
+ */
-class sobim_converter_impl implements sobim_converter {
- private $baseUrl = "http://localhost:8080/bm/rest/";
- private $fileToSend;
-
- public function __construct() {
- if(!$this->iscurlinstalled()) {
- throw new Exception("Curl library is required for this
to work!");
- }
+ interface sobim_converter
+ {
+
+ public function getFacilityManagementXml();
+
+ public function setBaseUrl($url);
}
- private function iscurlinstalled() {
- return (in_array ('curl', get_loaded_extensions()));
- }
-
- public function getFacilityManagementXml() {
- $this->checkArgumentsForXmlDownload();
- $restCall = "uploadIfc";
- $url = $this->baseUrl.$restCall;
- $verb = "POST";
- $data = array (
- 'file'=>'@'.$this->fileToSend
- );
-
- $rest = new RestRequest($url, $verb, $data);
-
- $rest->setAcceptType("application/xml");
- $rest->execute();
- //echo "SObim converter: response info\n";
- //print_r($rest->getResponseInfo());
- if( $rest->isError()) {
- $info = $rest->getResponseInfo();
- $http_code = $info["http_code"];
- if($http_code == 0) {
- throw new NoResponseException();
+
+ class sobim_converter_impl implements sobim_converter
+ {
+
+ private $baseUrl = "http://localhost:8080/bm/rest/";
+ private $fileToSend;
+
+ public function __construct()
+ {
+ if(!$this->iscurlinstalled())
+ {
+ throw new Exception("Curl library is required
for this to work!");
}
- throw new Exception("Rest call error :
".var_export($rest->getResponseInfo()));
}
- return $rest->getResponseBody();
- }
- public function checkArgumentsForXmlDownload() {
- if(empty($this->fileToSend)) {
- throw new InvalidArgumentException("File to send has
not been specified");
+
+ private function iscurlinstalled()
+ {
+ return (in_array('curl', get_loaded_extensions()));
}
- if(!file_exists($this->fileToSend)) {
- throw new InvalidArgumentException("File to send not
found in filesystem");
+
+ public function getFacilityManagementXml()
+ {
+ $this->checkArgumentsForXmlDownload();
+ $restCall = "uploadIfc";
+ $url = $this->baseUrl . $restCall;
+ $verb = "POST";
+ $data = array(
+ 'file' => '@' . $this->fileToSend
+ );
+
+ $rest = new RestRequest($url, $verb, $data);
+
+ $rest->setAcceptType("application/xml");
+ $rest->execute();
+ //echo "SObim converter: response info\n";
+ //print_r($rest->getResponseInfo());
+ if($rest->isError())
+ {
+ $info = $rest->getResponseInfo();
+ $http_code = $info["http_code"];
+ if($http_code == 0)
+ {
+ throw new NoResponseException();
+ }
+ throw new Exception("Rest call error : " .
var_export($rest->getResponseInfo()));
+ }
+ return $rest->getResponseBody();
}
- if(empty($this->baseUrl) || strlen($this->baseUrl) < 2) {
- throw new InvalidArgumentException("Base url not set!");
+
+ public function checkArgumentsForXmlDownload()
+ {
+ if(empty($this->fileToSend))
+ {
+ throw new InvalidArgumentException("File to
send has not been specified");
+ }
+ if(!file_exists($this->fileToSend))
+ {
+ throw new InvalidArgumentException("File to
send not found in filesystem");
+ }
+ if(empty($this->baseUrl) || strlen($this->baseUrl) < 2)
+ {
+ throw new InvalidArgumentException("Base url
not set!");
+ }
}
- }
- public function getRepositoryCountJson() {
-
- $url = $this->baseUrl."uploadIfc";
- $method = "GET";
- $rest = new RestRequest($url, $method);
- //$rest->setAcceptType("application/xml");
- $rest->execute();
- $output = $rest->getResponseBody();
- echo $output;
- }
- public function setBaseUrl($url) {
- if(substr($url, -1) != "/") {
- $url = $url . "/";
+
+ public function getRepositoryCountJson()
+ {
+
+ $url = $this->baseUrl . "uploadIfc";
+ $method = "GET";
+ $rest = new RestRequest($url, $method);
+ //$rest->setAcceptType("application/xml");
+ $rest->execute();
+ $output = $rest->getResponseBody();
+ echo $output;
}
- $this->baseUrl = $url;
- }
-
- public function getRepositoryNames() {
- $url = $this->baseUrl."/names";
- $method = "GET";
- $rest = new RestRequest($url, $method);
- //$rest->setAcceptType("application/xml");
- $rest->execute();
- $output = $rest->getResponseBody();
- echo $output;
- }
- public function setFileToSend($name) {
- $this->fileToSend = $name;
- }
-}
+
+ public function setBaseUrl($url)
+ {
+ if(substr($url, -1) != "/")
+ {
+ $url = $url . "/";
+ }
+ $this->baseUrl = $url;
+ }
+
+ public function getRepositoryNames()
+ {
+ $url = $this->baseUrl . "/names";
+ $method = "GET";
+ $rest = new RestRequest($url, $method);
+ //$rest->setAcceptType("application/xml");
+ $rest->execute();
+ $output = $rest->getResponseBody();
+ echo $output;
+ }
+
+ public function setFileToSend($name)
+ {
+ $this->fileToSend = $name;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobim_repository.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobim_repository.inc.php
2016-01-05 08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobim_repository.inc.php
2016-01-05 08:48:25 UTC (rev 14621)
@@ -1,45 +1,56 @@
<?php
-/*
- * Requires the following to work:
- * Curl library
- * HTTP_Request (Pear)
- */
+ /*
+ * Requires the following to work:
+ * Curl library
+ * HTTP_Request (Pear)
+ */
-phpgw::import_class('bim.restrequest');
+ phpgw::import_class('bim.restrequest');
-interface sobimrest {
- public function getRepositoryCountJson();
-}
+ interface sobimrest
+ {
-class sobimrest_impl implements sobimrest{
- private $baseUrl = "http://localhost:8080/RestTests/rest/repositories";
-
- public function __construct() {
- if(!$this->iscurlinstalled()) {
- throw new Exception("Curl library is required for this
to work!");
+ public function getRepositoryCountJson();
+ }
+
+ class sobimrest_impl implements sobimrest
+ {
+
+ private $baseUrl =
"http://localhost:8080/RestTests/rest/repositories";
+
+ public function __construct()
+ {
+ if(!$this->iscurlinstalled())
+ {
+ throw new Exception("Curl library is required
for this to work!");
+ }
}
- }
- private function iscurlinstalled() {
- return (in_array ('curl', get_loaded_extensions()));
- }
- public function getRepositoryCountJson() {
-
- $url = $this->baseUrl."/count";
- $method = "GET";
- $rest = new RestRequest($url, $method);
- //$rest->setAcceptType("application/xml");
- $rest->execute();
- $output = $rest->getResponseBody();
- echo $output;
- }
-
- public function getRepositoryNames() {
- $url = $this->baseUrl."/names";
- $method = "GET";
- $rest = new RestRequest($url, $method);
- //$rest->setAcceptType("application/xml");
- $rest->execute();
- $output = $rest->getResponseBody();
- echo $output;
- }
-}
+
+ private function iscurlinstalled()
+ {
+ return (in_array('curl', get_loaded_extensions()));
+ }
+
+ public function getRepositoryCountJson()
+ {
+
+ $url = $this->baseUrl . "/count";
+ $method = "GET";
+ $rest = new RestRequest($url, $method);
+ //$rest->setAcceptType("application/xml");
+ $rest->execute();
+ $output = $rest->getResponseBody();
+ echo $output;
+ }
+
+ public function getRepositoryNames()
+ {
+ $url = $this->baseUrl . "/names";
+ $method = "GET";
+ $rest = new RestRequest($url, $method);
+ //$rest->setAcceptType("application/xml");
+ $rest->execute();
+ $output = $rest->getResponseBody();
+ echo $output;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobimitem.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobimitem.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobimitem.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,208 +1,261 @@
<?php
+ phpgw::import_class('bim.sobim');
+ phpgw::import_class('bim.bimitem');
-phpgw::import_class('bim.sobim');
-phpgw::import_class('bim.bimitem');
+ interface sobimitem extends sobim
+ {
+ /*
+ * @return array of BIM objects
+ */
-interface sobimitem extends sobim {
- /*
- * @return array of BIM objects
- */
- public function getAll();
- /*
- * @param int id
- * @return BIMItem
- */
- public function getBimItem($bimObjectId);
- public function addBimItem($bimItem);
- public function deleteBimItem($guid);
- public function checkIfBimItemExists($guid);
- public function updateBimItem($bimItem);
- public function getBimItemAttributeValue($bimItemGuid, $attribute);
- public function retrieveItemsByModelId();
- public function setModelId($modelId);
-}
-class sobimitem_impl implements sobimitem
-{
- /* @var phpgwapi_db_ */
- private $db;
- private $modelId;
+ public function getAll();
+ /*
+ * @param int id
+ * @return BIMItem
+ */
- public function __construct(& $db) {
- // $this->db = & $GLOBALS['phpgw']->db;
- $this->db = $db;
- $db->Halt_On_Error = 'no';
- $db->Exception_On_Error = true;
+ public function getBimItem($bimObjectId);
+
+ public function addBimItem($bimItem);
+
+ public function deleteBimItem($guid);
+
+ public function checkIfBimItemExists($guid);
+
+ public function updateBimItem($bimItem);
+
+ public function getBimItemAttributeValue($bimItemGuid,
$attribute);
+
+ public function retrieveItemsByModelId();
+
+ public function setModelId($modelId);
}
- /*
- * @return Array an array of BimItem objects
- */
- public function getAll() {
- $itemTable = self::bimItemTable;
- $typeTable = self::bimTypeTable;
- $sql = "SELECT $itemTable.id, fm_bim_type.name AS type,
$itemTable.guid, $itemTable.xml_representation ".
- "FROM public. $itemTable,
public.$typeTable ".
- "WHERE $itemTable.type =
$typeTable.id";
- $bimItemArray = array();
- $this->db->query($sql);
- while($this->db->next_record())
+
+ class sobimitem_impl implements sobimitem
+ {
+ /* @var phpgwapi_db_ */
+
+ private $db;
+ private $modelId;
+
+ public function __construct(& $db)
{
- $bimItem = new
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'),
$this->db->f('xml_representation',true));
- array_push($bimItemArray, $bimItem);
+ // $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = $db;
+ $db->Halt_On_Error = 'no';
+ $db->Exception_On_Error = true;
}
+ /*
+ * @return Array an array of BimItem objects
+ */
- return $bimItemArray;
- }
+ public function getAll()
+ {
+ $itemTable = self::bimItemTable;
+ $typeTable = self::bimTypeTable;
+ $sql = "SELECT $itemTable.id, fm_bim_type.name AS type,
$itemTable.guid, $itemTable.xml_representation " .
+ "FROM public. $itemTable, public.$typeTable " .
+ "WHERE $itemTable.type = $typeTable.id";
+ $bimItemArray = array();
+ $this->db->query($sql);
+ while($this->db->next_record())
+ {
+ $bimItem = new BimItem($this->db->f('id'),
$this->db->f('guid'), $this->db->f('type'), $this->db->f('xml_representation',
true));
+ array_push($bimItemArray, $bimItem);
+ }
+ return $bimItemArray;
+ }
- public function getBimItem($bimObjectGuid){
- $itemTable = self::bimItemTable;
- $typeTable = self::bimTypeTable;
- $sql = "SELECT $itemTable.id, fm_bim_type.name AS type,
$itemTable.guid, $itemTable.xml_representation, $itemTable.model ".
- "FROM public.$itemTable,
public.$typeTable ".
- "WHERE $itemTable.type = $typeTable.id
" .
- "AND $itemTable.guid ='$bimObjectGuid'";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() == 0) {
- throw new Exception('Item not found!');
- } else {
+ public function getBimItem($bimObjectGuid)
+ {
+ $itemTable = self::bimItemTable;
+ $typeTable = self::bimTypeTable;
+ $sql = "SELECT $itemTable.id, fm_bim_type.name AS type,
$itemTable.guid, $itemTable.xml_representation, $itemTable.model " .
+ "FROM public.$itemTable, public.$typeTable " .
+ "WHERE $itemTable.type = $typeTable.id " .
+ "AND $itemTable.guid ='$bimObjectGuid'";
+ $this->db->query($sql, __LINE__, __FILE__);
+ if($this->db->num_rows() == 0)
+ {
+ throw new Exception('Item not found!');
+ }
+ else
+ {
+ $this->db->next_record();
+ return new BimItem($this->db->f('id'),
$this->db->f('guid'), $this->db->f('type'), $this->db->f('xml_representation',
true), $this->db->f('model'));
+ }
+ }
+
+ public function addBimItem($bimItem)
+ {
+ /* @var $bimItem BimItem */
+ if(!$bimItem->getModelId())
+ {
+ throw new Exception('ModelId not set');
+ }
+
+ $this->db->query("SELECT id as type FROM " .
self::bimTypeTable . " WHERE name = '" . $bimItem->getType(), __LINE__,
__FILE__);
$this->db->next_record();
- return new
BimItem($this->db->f('id'),$this->db->f('guid'), $this->db->f('type'),
$this->db->f('xml_representation',true),$this->db->f('model'));
+ $type = $this->db->f('type');
+ $id = $this->db->next_id('fm_bim_item', array('type' =>
$type));
+
+ $sql = "INSERT INTO " . self::bimItemTable . " (type,
id, guid, xml_representation, model) values ($type, $id,";
+ // $sql = $sql."(select id from
".self::bimTypeTable." where name = '".$bimItem->getType()."'),";
+ $sql = $sql . "'" . $bimItem->getGuid() . "', '" .
$this->db->db_addslashes($bimItem->getXml()) . "', " . $bimItem->getModelId() .
")";
+ try
+ {
+ if(is_null($this->db->query($sql, __LINE__,
__FILE__)))
+ {
+ throw new Exception('Query to add item
was unsuccessful');
+ }
+ else
+ {
+ return $this->db->num_rows();
+ }
+ }
+ catch(PDOException $e)
+ {
+ throw new BimDataException("Could not add
item", $e);
+ }
}
- }
-
- public function addBimItem($bimItem) {
- /* @var $bimItem BimItem */
- if(!$bimItem->getModelId())
+ /*
+ * Checks if the bim item exists
+ * @param string GUID
+ * @return boolean
+ */
+
+ public function checkIfBimItemExists($guid)
{
- throw new Exception('ModelId not set');
+ $resultAlias = 'test_item_count';
+ $sql = "SELECT count(id) as $resultAlias from public."
. self::bimItemTable . " where guid = '$guid'";
+
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Query to check items was
unsuccessful');
+ }
+ else
+ {
+ $this->db->next_record();
+ $rowCountOfItemTypes =
$this->db->f($resultAlias);
+ return (bool)$rowCountOfItemTypes;
+ }
}
-
- $this->db->query("SELECT id as type FROM ".self::bimTypeTable."
WHERE name = '".$bimItem->getType(),__LINE__,__FILE__);
- $this->db->next_record();
- $type = $this->db->f('type');
- $id = $this->db->next_id('fm_bim_item',array('type' =>
$type));
+ /*
+ * @return number of affected rows
+ */
- $sql = "INSERT INTO ".self::bimItemTable." (type, id, guid,
xml_representation, model) values ($type, $id,";
- // $sql = $sql."(select id from ".self::bimTypeTable." where name
= '".$bimItem->getType()."'),";
- $sql = $sql."'".$bimItem->getGuid()."',
'".$this->db->db_addslashes($bimItem->getXml())."',
".$bimItem->getModelId().")";
- try {
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to add item was
unsuccessful');
- } else {
+ public function deleteBimItem($guid)
+ {
+ $sql = "Delete from public." . self::bimItemTable . "
where guid = '$guid'";
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Query to delete item was
unsuccessful');
+ }
+ else
+ {
return $this->db->num_rows();
}
- }catch (PDOException $e) {
- throw new BimDataException("Could not add item",$e);
}
-
- }
- /*
- * Checks if the bim item exists
- * @param string GUID
- * @return boolean
- */
- public function checkIfBimItemExists($guid) {
- $resultAlias = 'test_item_count';
- $sql = "SELECT count(id) as $resultAlias from
public.".self::bimItemTable." where guid = '$guid'";
-
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to check items was
unsuccessful');
- } else {
- $this->db->next_record();
- $rowCountOfItemTypes = $this->db->f($resultAlias);
- return (bool)$rowCountOfItemTypes;
+
+ public function updateBimItem($bimItem)
+ {
+ if(!$this->checkIfBimItemExists($bimItem->getGuid()))
+ {
+ throw new Exception("Item does not exist!");
+ }
+ $sql = "Update " . self::bimItemTable . " set
xml_representation='" . $this->db->db_addslashes($bimItem->getXml()) . "' where
guid='" . $bimItem->getGuid() . "'";
+
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception("Error updating xml of bim
item!");
+ }
+ else
+ {
+ return (bool)$this->db->num_rows();
+ }
}
- }
- /*
- * @return number of affected rows
- */
- public function deleteBimItem($guid) {
- $sql = "Delete from public.".self::bimItemTable." where guid =
'$guid'";
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to delete item was
unsuccessful');
- } else {
- return $this->db->num_rows();
+ /*
+ * Searches the xml representation and returns the values of
any attributes that have the specified name
+ * If there are multiple elements with the same name, all of
their value's will be returned
+ * Note: the name can be written in xpath format in relation to
it's parent, so instead of 'name',
+ * you could write 'attributes/name'
+ * @access public
+ * @param string $bimItemGuid the guid of the item
+ * @param string $attribute the name of the attribute
+ * @throws Exception if nothing is found
+ * $return array results
+ */
+
+ public function getBimItemAttributeValue($bimItemGuid,
$attribute)
+ {
+ $columnAlias = "attribute_values";
+ $itemTable = self::bimItemTable;
+ //$sql = "select
xpath('descendant-or-self::*[$attribute]/$attribute/text()', (select
xml_representation from fm_bim_data where guid='$bimItemGuid'))";
+ $sql = "select
array_to_string(xpath('descendant-or-self::*[$attribute]/$attribute/text()',
(select xml_representation from $itemTable where guid='$bimItemGuid')), ',') as
$columnAlias";
+ $this->db->query($sql, __LINE__, __FILE__);
+ if($this->db->num_rows() == 0)
+ {
+ throw new Exception('Error!');
+ }
+ else
+ {
+ $this->db->next_record();
+ $result = $this->db->f($columnAlias, true);
+ return preg_split('/,/', $result);
+ //$match; // xpath result from database will
look like: '{data1, data2, data3}', or '{}' for no results
+ //preg_match('/^\{(.*)\}$/', $result, $match);
+ /* if(!$match[1]) {
+ throw new Exception('Attribute not found!');
+ } else {
+ return preg_split('/,/', $match[1]);
+ } */
+ }
}
- }
-
- public function updateBimItem($bimItem) {
- if(!$this->checkIfBimItemExists($bimItem->getGuid())) {
- throw new Exception("Item does not exist!");
- }
- $sql = "Update ".self::bimItemTable." set
xml_representation='".$this->db->db_addslashes($bimItem->getXml())."' where
guid='".$bimItem->getGuid()."'";
-
- if(is_null($this->db->query($sql,__LINE__,__FILE__) )){
- throw new Exception("Error updating xml of bim item!");
- } else {
- return (bool)$this->db->num_rows();
- }
- }
- /*
- * Searches the xml representation and returns the values of any
attributes that have the specified name
- * If there are multiple elements with the same name, all of their
value's will be returned
- * Note: the name can be written in xpath format in relation to it's
parent, so instead of 'name',
- * you could write 'attributes/name'
- * @access public
- * @param string $bimItemGuid the guid of the item
- * @param string $attribute the name of the attribute
- * @throws Exception if nothing is found
- * $return array results
- */
- public function getBimItemAttributeValue($bimItemGuid, $attribute) {
- $columnAlias = "attribute_values";
- $itemTable = self::bimItemTable;
- //$sql = "select
xpath('descendant-or-self::*[$attribute]/$attribute/text()', (select
xml_representation from fm_bim_data where guid='$bimItemGuid'))";
- $sql = "select
array_to_string(xpath('descendant-or-self::*[$attribute]/$attribute/text()',
(select xml_representation from $itemTable where guid='$bimItemGuid')), ',') as
$columnAlias";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() == 0) {
- throw new Exception('Error!');
- } else {
- $this->db->next_record();
- $result = $this->db->f($columnAlias,true);
- return preg_split('/,/', $result);
- //$match; // xpath result from database will look like:
'{data1, data2, data3}', or '{}' for no results
- //preg_match('/^\{(.*)\}$/', $result, $match);
- /*if(!$match[1]) {
- throw new Exception('Attribute not found!');
- } else {
- return preg_split('/,/', $match[1]);
- }*/
- }
- }
- /*
- * Needs the modelId field set
- */
- public function retrieveItemsByModelId() {
- if(empty($this->modelId)) {
- throw new InvalidArgumentException("Missing modelId!");
- }
- $itemTable = self::bimItemTable;
- $typeTable = self::bimTypeTable;
- $bimItems = array();
- $sql = "select $itemTable.id, (select name from fm_bim_type
where $itemTable.type = $typeTable.id) as type, $itemTable.guid from $itemTable
where $itemTable.model =".$this->modelId;
- try {
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() == 0) {
- return null;
- } else {
- while($this->db->next_record())
+ /*
+ * Needs the modelId field set
+ */
+
+ public function retrieveItemsByModelId()
+ {
+ if(empty($this->modelId))
+ {
+ throw new InvalidArgumentException("Missing
modelId!");
+ }
+ $itemTable = self::bimItemTable;
+ $typeTable = self::bimTypeTable;
+ $bimItems = array();
+ $sql = "select $itemTable.id, (select name from
fm_bim_type where $itemTable.type = $typeTable.id) as type, $itemTable.guid
from $itemTable where $itemTable.model =" . $this->modelId;
+ try
+ {
+ $this->db->query($sql, __LINE__, __FILE__);
+ if($this->db->num_rows() == 0)
{
- $bimItem = new
BimItem($this->db->f('id'),$this->db->f('guid'),$this->db->f('type'));
- array_push($bimItems, $bimItem);
+ return null;
}
- return $bimItems;
+ else
+ {
+ while($this->db->next_record())
+ {
+ $bimItem = new
BimItem($this->db->f('id'), $this->db->f('guid'), $this->db->f('type'));
+ array_push($bimItems, $bimItem);
+ }
+ return $bimItems;
+ }
}
- } catch (Exception $e) {
- throw $e;
+ catch(Exception $e)
+ {
+ throw $e;
+ }
}
- }
-
- public function setModelId($modelId) {
- $this->modelId = $modelId;
- }
- public function getModelId() {
- return $this->modelId;
- }
-
-}
+ public function setModelId($modelId)
+ {
+ $this->modelId = $modelId;
+ }
+
+ public function getModelId()
+ {
+ return $this->modelId;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobimmodel.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobimmodel.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobimmodel.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,219 +1,282 @@
<?php
+ phpgw::import_class('bim.bimExceptions');
+ phpgw::import_class('bim.bimmodel');
+ phpgw::import_class('bim.bimmodelinformation');
-phpgw::import_class('bim.bimExceptions');
-phpgw::import_class('bim.bimmodel');
-phpgw::import_class('bim.bimmodelinformation');
-
-/*
- * @see sobimmodel_impl
- */
-interface sobimmodel extends sobim{
-
- public function addBimModel();
- public function retrieveBimModelList();
- public function retrieveBimModelInformationById();
- public function removeBimModelByIdFromDatabase();
/*
- * @throws InvalidArgumentException If the arguments are not set
- * @throws ModelExistsException if the model does not exist
- * @throws Exception When sql request fails
- * @return boolean true if success
+ * @see sobimmodel_impl
*/
- public function removeBimModelFromDatabase();
- /*
- * @return boolean
- */
- public function checkIfModelExists();
- public function setModelName($name);
- public function getModelName();
- /*
- * set virtual file id from database
- */
- public function setVfsdatabaseid(int $id);
- public function getVfsdatabaseid();
-
- public function setModelId(int $id);
- public function getModelId();
-
-
-}
-class sobimmodel_impl implements sobimmodel
-{
-
- private $db;
- private $modelName;
- private $vfs_database_id;
- private $modelId;
- public function __construct(& $db, $modelName = null, $vfs_id = null) {
- // $this->db = & $GLOBALS['phpgw']->db;
- $this->db = $db;
- $db->Halt_On_Error = 'no';
- $db->Exception_On_Error = true;
+ interface sobimmodel extends sobim
+ {
+
+ public function addBimModel();
+
+ public function retrieveBimModelList();
+
+ public function retrieveBimModelInformationById();
+
+ public function removeBimModelByIdFromDatabase();
+ /*
+ * @throws InvalidArgumentException If the arguments are not set
+ * @throws ModelExistsException if the model does not exist
+ * @throws Exception When sql request fails
+ * @return boolean true if success
+ */
+
+ public function removeBimModelFromDatabase();
+ /*
+ * @return boolean
+ */
+
+ public function checkIfModelExists();
+
+ public function setModelName($name);
+
+ public function getModelName();
+ /*
+ * set virtual file id from database
+ */
+
+ public function setVfsdatabaseid(int $id);
+
+ public function getVfsdatabaseid();
+
+ public function setModelId(int $id);
+
+ public function getModelId();
}
-
- public function retrieveBimModelList() {
- $bimModelArray = array();
- $itemTable = self::bimItemTable;
- $modelTable = self::bimModelTable;
- $sql = "select model.id,model.name,vfs.created,vfs.size as
filesize,vfs.name as filename,vfs.file_id as vfs_file_id,(select count(*) from
$itemTable where model=model.id) as used_item_count from $modelTable as model
left join phpgw_vfs as vfs on model.vfs_file_id = vfs.file_id";
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to find bim models failed');
- } else {
- if($this->db->num_rows() == 0) {
- return null;
- } else {
- while($this->db->next_record())
+
+ class sobimmodel_impl implements sobimmodel
+ {
+
+ private $db;
+ private $modelName;
+ private $vfs_database_id;
+ private $modelId;
+
+ public function __construct(& $db, $modelName = null, $vfs_id =
null)
+ {
+ // $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = $db;
+ $db->Halt_On_Error = 'no';
+ $db->Exception_On_Error = true;
+ }
+
+ public function retrieveBimModelList()
+ {
+ $bimModelArray = array();
+ $itemTable = self::bimItemTable;
+ $modelTable = self::bimModelTable;
+ $sql = "select model.id,model.name,vfs.created,vfs.size
as filesize,vfs.name as filename,vfs.file_id as vfs_file_id,(select count(*)
from $itemTable where model=model.id) as used_item_count from $modelTable as
model left join phpgw_vfs as vfs on model.vfs_file_id = vfs.file_id";
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Query to find bim models
failed');
+ }
+ else
+ {
+ if($this->db->num_rows() == 0)
{
- $bimModel =
$this->assembleBimModelFromCurrentDatabaseRecord();
- array_push($bimModelArray, $bimModel);
+ return null;
}
+ else
+ {
+ while($this->db->next_record())
+ {
+ $bimModel =
$this->assembleBimModelFromCurrentDatabaseRecord();
+ array_push($bimModelArray,
$bimModel);
+ }
+ }
}
+ return $bimModelArray;
}
- return $bimModelArray;
- }
- private function assembleBimModelFromCurrentDatabaseRecord() {
- $bimModel = new BimModel();
- $bimModel->setDatabaseId($this->db->f('id'));
- $bimModel->setName($this->db->f('name'));
- $bimModel->setCreationDate($this->db->f('created'));
- $bimModel->setFileSize($this->db->f('filesize'));
- $bimModel->setFileName($this->db->f('filename'));
- $bimModel->setUsedItemCount($this->db->f('used_item_count'));
- $bimModel->setVfsFileId($this->db->f('vfs_file_id'));
- return $bimModel;
- }
- /*
- * Needs modelId set
- * @throws ModelDoesNotExistException
- * @return null|BimModel
- */
- public function retrieveBimModelInformationById() {
- $this->checkArgModelId();
- $itemTable = self::bimItemTable;
- $modelTable = self::bimModelTable;
- $sql = "Select * from $modelTable where id=".$this->modelId;
- $sql = "select model.id,model.name,vfs.created,vfs.size as
filesize,vfs.name as filename,vfs.file_id as vfs_file_id,".
- "(select count(*) from $itemTable where
model=model.id) as used_item_count from $modelTable as model ".
- "left join phpgw_vfs as vfs on
model.vfs_file_id = vfs.file_id where id=".$this->modelId;
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to find bim model failed');
- } else {
- if($this->db->num_rows() == 0) {
- throw new ModelDoesNotExistException();
- } else {
- $this->db->next_record();
-
+
+ private function assembleBimModelFromCurrentDatabaseRecord()
+ {
+ $bimModel = new BimModel();
+ $bimModel->setDatabaseId($this->db->f('id'));
+ $bimModel->setName($this->db->f('name'));
+ $bimModel->setCreationDate($this->db->f('created'));
+ $bimModel->setFileSize($this->db->f('filesize'));
+ $bimModel->setFileName($this->db->f('filename'));
+
$bimModel->setUsedItemCount($this->db->f('used_item_count'));
+ $bimModel->setVfsFileId($this->db->f('vfs_file_id'));
+ return $bimModel;
+ }
+ /*
+ * Needs modelId set
+ * @throws ModelDoesNotExistException
+ * @return null|BimModel
+ */
+
+ public function retrieveBimModelInformationById()
+ {
+ $this->checkArgModelId();
+ $itemTable = self::bimItemTable;
+ $modelTable = self::bimModelTable;
+ $sql = "Select * from $modelTable where id=" .
$this->modelId;
+ $sql = "select model.id,model.name,vfs.created,vfs.size
as filesize,vfs.name as filename,vfs.file_id as vfs_file_id," .
+ "(select count(*) from $itemTable where model=model.id)
as used_item_count from $modelTable as model " .
+ "left join phpgw_vfs as vfs on model.vfs_file_id =
vfs.file_id where id=" . $this->modelId;
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Query to find bim model
failed');
+ }
+ else
+ {
+ if($this->db->num_rows() == 0)
+ {
+ throw new ModelDoesNotExistException();
+ }
+ else
+ {
+ $this->db->next_record();
+
// $bimModel = new BimModel();
// $bimModel->setDatabaseId($this->db->f('id'));
// $bimModel->setName($this->db->f('name'));
//
$bimModel->setVfsFileId($this->db->f('vfs_file_id'));
- $bimModel =
$this->assembleBimModelFromCurrentDatabaseRecord();
- return $bimModel;
+ $bimModel =
$this->assembleBimModelFromCurrentDatabaseRecord();
+ return $bimModel;
+ }
}
}
- }
- public function removeBimModelByIdFromDatabase(){
- $this->checkArgModelId();
- $sql = "Delete from ".self::bimModelTable." where
id=".$this->modelId;
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to delete model was
unsuccessful');
- } else {
- return $this->db->num_rows();
- }
- }
- public function addBimModel() {
- if(!$this->checkIfModelExists()) {
- $sql = "INSERT INTO ".self::bimModelTable." (name,
vfs_file_id) values ('$this->modelName',$this->vfs_database_id)";
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to add model was
unsuccessful');
- } else {
+
+ public function removeBimModelByIdFromDatabase()
+ {
+ $this->checkArgModelId();
+ $sql = "Delete from " . self::bimModelTable . " where
id=" . $this->modelId;
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Query to delete model was
unsuccessful');
+ }
+ else
+ {
return $this->db->num_rows();
}
- } else {
- throw new ModelExistsException('Model already exists');
}
- }
-
- public function checkIfModelExists() {
- $this->checkArgs();
- $resultAlias = "id";
-
- $sql = "select count(*) as $resultAlias from
".sobim::bimModelTable." where name = '$this->modelName' and
vfs_file_id=$this->vfs_database_id";
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Error checking if model exists!');
- } else {
+
+ public function addBimModel()
+ {
+ if(!$this->checkIfModelExists())
+ {
+ $sql = "INSERT INTO " . self::bimModelTable . "
(name, vfs_file_id) values ('$this->modelName',$this->vfs_database_id)";
+ if(is_null($this->db->query($sql, __LINE__,
__FILE__)))
+ {
+ throw new Exception('Query to add model
was unsuccessful');
+ }
+ else
+ {
+ return $this->db->num_rows();
+ }
+ }
+ else
+ {
+ throw new ModelExistsException('Model already
exists');
+ }
+ }
+
+ public function checkIfModelExists()
+ {
+ $this->checkArgs();
+ $resultAlias = "id";
+
+ $sql = "select count(*) as $resultAlias from " .
sobim::bimModelTable . " where name = '$this->modelName' and
vfs_file_id=$this->vfs_database_id";
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
+ throw new Exception('Error checking if model
exists!');
+ }
+ else
+ {
+ $this->db->next_record();
+ $rowCountOfModels = $this->db->f($resultAlias);
+ return ($rowCountOfModels > 0);
+ }
+ }
+ /*
+ * @see sobimmodel
+ */
+
+ public function removeBimModelFromDatabase()
+ {
+ $this->checkArgs();
+ if(!$this->checkIfModelExists())
+ {
+ throw new ModelExistsException("Model does not
exist");
+ }
+ if(!$this->removeBimModelDatabaseEntry())
+ {
+ throw new Exception("Error removing sql model");
+ }
+ return true;
+ }
+
+ private function removeBimModelDatabaseEntry()
+ {
+ $sql = "SELECT id FROM " . sobim::bimModelTable . "
WHERE name = '$this->modelName' AND vfs_file_id=$this->vfs_database_id";
+ $this->db->query($sql, __LINE__, __FILE__);
$this->db->next_record();
- $rowCountOfModels = $this->db->f($resultAlias);
- return ($rowCountOfModels > 0);
+ $model_id = (int)$this->db->f('id');
+
+ $this->db->transaction_begin();
+ $sql = "DELETE FROM public." . sobim::bimItemTable . "
WHERE model = '$model_id'";
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ $sql = "DELETE FROM " . sobim::bimModelTable . " WHERE
name = '$this->modelName' AND vfs_file_id=$this->vfs_database_id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ if($this->db->transaction_commit())
+ {
+ return ($this->db->num_rows() > 0);
+ }
+ else
+ {
+ throw new Exception('Query to delete model was
unsuccessful');
+ }
}
- }
- /*
- * @see sobimmodel
- */
- public function removeBimModelFromDatabase() {
- $this->checkArgs();
- if(!$this->checkIfModelExists()) {
- throw new ModelExistsException("Model does not exist");
+
+ private function checkArgs()
+ {
+ if(!$this->modelName ||
!is_int($this->getVfsdatabaseid()) || $this->getVfsdatabaseid() == 0)
+ {
+ throw new InvalidArgumentException("Invalid
arguments! \n modelname: $this->modelName \n VFS ID : $this->vfs_database_id");
+ }
}
- if(!$this->removeBimModelDatabaseEntry()) {
- throw new Exception("Error removing sql model");
+
+ private function checkArgModelId()
+ {
+ if(!$this->modelId)
+ {
+ throw new InvalidArgumentException("Invalid
arguments! \n modelid: $this->modelId");
+ }
}
- return true;
- }
- private function removeBimModelDatabaseEntry()
- {
- $sql = "SELECT id FROM ".sobim::bimModelTable." WHERE name =
'$this->modelName' AND vfs_file_id=$this->vfs_database_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $model_id = (int)$this->db->f('id');
-
- $this->db->transaction_begin();
- $sql = "DELETE FROM public.".sobim::bimItemTable." WHERE model
= '$model_id'";
- $this->db->query($sql,__LINE__,__FILE__);
+ public function setModelName($name)
+ {
+ $this->modelName = $name;
+ }
- $sql = "DELETE FROM ".sobim::bimModelTable." WHERE name =
'$this->modelName' AND vfs_file_id=$this->vfs_database_id";
- $this->db->query($sql,__LINE__,__FILE__);
- if( $this->db->transaction_commit() )
+ public function getModelName()
{
- return ($this->db->num_rows() > 0);
+ return $this->modelName;
}
- else
+
+ public function setVfsdatabaseid(int $id)
{
- throw new Exception('Query to delete model was
unsuccessful');
+ $this->vfs_database_id = (int)$id;
}
- }
-
- private function checkArgs() {
- if(!$this->modelName || !is_int($this->getVfsdatabaseid()) ||
$this->getVfsdatabaseid() == 0) {
- throw new InvalidArgumentException("Invalid arguments!
\n modelname: $this->modelName \n VFS ID : $this->vfs_database_id");
+
+ public function getVfsdatabaseid()
+ {
+ return $this->vfs_database_id;
}
- }
- private function checkArgModelId() {
- if(!$this->modelId) {
- throw new InvalidArgumentException("Invalid arguments!
\n modelid: $this->modelId");
+
+ public function getModelId()
+ {
+ return $this->modelId;
}
- }
-
- public function setModelName($name) {
- $this->modelName = $name;
- }
- public function getModelName() {
- return $this->modelName;
- }
- public function setVfsdatabaseid(int $id) {
- $this->vfs_database_id = (int) $id;
- }
- public function getVfsdatabaseid() {
- return $this->vfs_database_id;
- }
- public function getModelId() {
- return $this->modelId;
- }
- public function setModelId(int $id) {
- $this->modelId = $id;
- }
-}
-
+ public function setModelId(int $id)
+ {
+ $this->modelId = $id;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobimmodelinformation.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobimmodelinformation.inc.php
2016-01-05 08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobimmodelinformation.inc.php
2016-01-05 08:48:25 UTC (rev 14621)
@@ -1,166 +1,209 @@
<?php
+ phpgw::import_class('bim.bimExceptions');
+ phpgw::import_class('bim.bimmodelinformation');
-phpgw::import_class('bim.bimExceptions');
-phpgw::import_class('bim.bimmodelinformation');
-
-/*
- * @see sobimmodel_impl
- */
-interface sobimmodelinformation extends sobim{
- public function setModelId(int $id);
- public function setDb(phpgwapi_db_ $db);
- public function setBimModelInformation(BimModelInformation $binfo);
/*
- * Will need db, modelId set and modelinformation object set
- * @throws InvalidArgumentException
+ * @see sobimmodel_impl
*/
- public function updateModelInformation();
- /*
- * Will need db and modelId
- */
- public function getModelInformation();
-
-}
-class sobimmodelinformation_impl implements sobimmodelinformation
-{
-
- private $db;
- private $modelId;
- private $modelInformation;
- private $modelInformationColumns;// = array('authorization_value',
'author', 'changedate', 'description', 'organization', 'originatingsystem',
'preprocessor', 'valdate', 'nativeSchema');
- private $modelInformationMapping;
- public function __construct(phpgwapi_db_ & $db,int $modelId = null,
BimModelInformation $modelInformation = null) {
- $this->db = $db;
- $db->Halt_On_Error = 'no';
- $db->Exception_On_Error = true;
- $this->modelId = $modelId;
-
- $this->modelInformation = $modelInformation;
- $this->initModelInformationColumns();
+
+ interface sobimmodelinformation extends sobim
+ {
+
+ public function setModelId(int $id);
+
+ public function setDb(phpgwapi_db_ $db);
+
+ public function setBimModelInformation(BimModelInformation
$binfo);
+ /*
+ * Will need db, modelId set and modelinformation object set
+ * @throws InvalidArgumentException
+ */
+
+ public function updateModelInformation();
+ /*
+ * Will need db and modelId
+ */
+
+ public function getModelInformation();
}
- /*
- * MAP db column names to BimModelInformation methods, but without the
get/set prefix
- */
- private function initModelInformationColumns() {
- $modelInformationMapping = array();
- $modelInformationMapping['authorization_value'] =
"Authorization";
- $modelInformationMapping['author'] = "Author";
- $modelInformationMapping['changedate'] = "ChangeDate";
- $modelInformationMapping['description'] = "Description";
- $modelInformationMapping['organization'] = "Organization";
- $modelInformationMapping['originatingsystem'] =
"OriginatingSystem";
- $modelInformationMapping['preprocessor'] = "PreProcessor";
- $modelInformationMapping['valdate'] = "ValDate";
- $modelInformationMapping['nativeschema'] = "NativeSchema";
- $this->modelInformationMapping = $modelInformationMapping;
- $this->modelInformationColumns =
array_keys($modelInformationMapping);
- }
- public function updateModelInformation() {
- $this->checkArgumentsForUpdate();
- $modelTable = self::bimModelTable;
- $sql = "update $modelTable set ".
-
"(".implode(",",$this->modelInformationColumns).") =".
-
$this->getModelInfoSqlValueString($this->modelInformation).
- " where id=".$this->modelId;
-
- try {
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to add model
information was unsuccessful');
- } else {
- return $this->db->num_rows();
+
+ class sobimmodelinformation_impl implements sobimmodelinformation
+ {
+
+ private $db;
+ private $modelId;
+ private $modelInformation;
+ private $modelInformationColumns;// =
array('authorization_value', 'author', 'changedate', 'description',
'organization', 'originatingsystem', 'preprocessor', 'valdate', 'nativeSchema');
+ private $modelInformationMapping;
+
+ public function __construct(phpgwapi_db_ & $db, int $modelId =
null, BimModelInformation $modelInformation = null)
+ {
+ $this->db = $db;
+ $db->Halt_On_Error = 'no';
+ $db->Exception_On_Error = true;
+ $this->modelId = $modelId;
+
+ $this->modelInformation = $modelInformation;
+ $this->initModelInformationColumns();
+ }
+ /*
+ * MAP db column names to BimModelInformation methods, but
without the get/set prefix
+ */
+
+ private function initModelInformationColumns()
+ {
+ $modelInformationMapping = array();
+ $modelInformationMapping['authorization_value'] =
"Authorization";
+ $modelInformationMapping['author'] = "Author";
+ $modelInformationMapping['changedate'] = "ChangeDate";
+ $modelInformationMapping['description'] = "Description";
+ $modelInformationMapping['organization'] =
"Organization";
+ $modelInformationMapping['originatingsystem'] =
"OriginatingSystem";
+ $modelInformationMapping['preprocessor'] =
"PreProcessor";
+ $modelInformationMapping['valdate'] = "ValDate";
+ $modelInformationMapping['nativeschema'] =
"NativeSchema";
+ $this->modelInformationMapping =
$modelInformationMapping;
+ $this->modelInformationColumns =
array_keys($modelInformationMapping);
+ }
+
+ public function updateModelInformation()
+ {
+ $this->checkArgumentsForUpdate();
+ $modelTable = self::bimModelTable;
+ $sql = "update $modelTable set " .
+ "(" . implode(",", $this->modelInformationColumns) . ")
=" .
+
$this->getModelInfoSqlValueString($this->modelInformation) .
+ " where id=" . $this->modelId;
+
+ try
+ {
+ if(is_null($this->db->query($sql, __LINE__,
__FILE__)))
+ {
+ throw new Exception('Query to add model
information was unsuccessful');
+ }
+ else
+ {
+ return $this->db->num_rows();
+ }
}
- } catch (Exception $e) {
- throw $e;
- }
-
- }
- private function checkArgumentsForUpdate() {
- if(empty($this->db) || empty($this->modelId) ||
empty($this->modelInformation)|| !($this->modelInformation instanceof
BimModelInformation) ) {
- $error = "(sobimmodelinformation)Model
id:".$this->modelId." \n".
- "Model
information:".gettype($this->modelInformation)."\n".
- "Model information
class:".get_class($this->modelInformation)."\n".
- "DB:".gettype($this->db)."\n";
- throw new InvalidArgumentException($error);
+ catch(Exception $e)
+ {
+ throw $e;
+ }
}
- }
- private function checkArgumentsForRead() {
- if(empty($this->db) || empty($this->modelId) ) {
- $error = "Model id:".$this->modelId." \n".
- "DB:".gettype($this->db)."\n";
- throw new InvalidArgumentException($error);
+
+ private function checkArgumentsForUpdate()
+ {
+ if(empty($this->db) || empty($this->modelId) ||
empty($this->modelInformation) || !($this->modelInformation instanceof
BimModelInformation))
+ {
+ $error = "(sobimmodelinformation)Model id:" .
$this->modelId . " \n" .
+ "Model information:" .
gettype($this->modelInformation) . "\n" .
+ "Model information class:" .
get_class($this->modelInformation) . "\n" .
+ "DB:" . gettype($this->db) . "\n";
+ throw new InvalidArgumentException($error);
+ }
}
- }
- /*
- * Adds the values in the correct order into an array
- */
- private function getModelInfoSqlValueString(BimModelInformation
$modelInfo) {
- $modelInfoValues = array();
- foreach(array_values($this->modelInformationMapping) as
$methodName) {
- $cmd =
'array_push($modelInfoValues,$this->modelInformation->get'.$methodName.'());';
- eval($cmd);
+
+ private function checkArgumentsForRead()
+ {
+ if(empty($this->db) || empty($this->modelId))
+ {
+ $error = "Model id:" . $this->modelId . " \n" .
+ "DB:" . gettype($this->db) . "\n";
+ throw new InvalidArgumentException($error);
+ }
}
- foreach($modelInfoValues as &$value) {
- $value = (empty($value)) ? 'null' :
"'".addslashes($value)."'";
+ /*
+ * Adds the values in the correct order into an array
+ */
+
+ private function getModelInfoSqlValueString(BimModelInformation
$modelInfo)
+ {
+ $modelInfoValues = array();
+ foreach(array_values($this->modelInformationMapping) as
$methodName)
+ {
+ $cmd =
'array_push($modelInfoValues,$this->modelInformation->get' . $methodName .
'());';
+ eval($cmd);
+ }
+ foreach($modelInfoValues as &$value)
+ {
+ $value = (empty($value)) ? 'null' : "'" .
addslashes($value) . "'";
+ }
+ $sqlString = "(" . implode(",", $modelInfoValues) . ")";
+ return $sqlString;
+
+ /*
array_push($modelInfoArray,$this->modelInformation->getAuthorization());
+
array_push($modelInfoArray,$this->modelInformation->getAuthor());
+
array_push($modelInfoArray,$this->modelInformation->getChangeDate());
+
array_push($modelInfoArray,$this->modelInformation->getDescription());
+
array_push($modelInfoArray,$this->modelInformation->getOrganization());
+
array_push($modelInfoArray,$this->modelInformation->getOriginatingSystem());
+
array_push($modelInfoArray,$this->modelInformation->getPreProcessor());
+
array_push($modelInfoArray,$this->modelInformation->getValDate());
+
array_push($modelInfoArray,$this->modelInformation->getNativeSchema());
+ $sqlString = "(";
+ foreach($modelInfoArray as $value) {
+ $valueString = (empty($value)) ? 'null' :
"'".addslashes($value)."'";
+ $sqlString = $sqlString.$valueString.",";
+ }
+ $sqlString = substr($sqlString,0,-1);
+ $sqlString = $sqlString.")";
+ return $sqlString; */
}
- $sqlString = "(".implode(",", $modelInfoValues).")";
- return $sqlString;
-
-
/*array_push($modelInfoArray,$this->modelInformation->getAuthorization());
-
array_push($modelInfoArray,$this->modelInformation->getAuthor());
-
array_push($modelInfoArray,$this->modelInformation->getChangeDate());
-
array_push($modelInfoArray,$this->modelInformation->getDescription());
-
array_push($modelInfoArray,$this->modelInformation->getOrganization());
-
array_push($modelInfoArray,$this->modelInformation->getOriginatingSystem());
-
array_push($modelInfoArray,$this->modelInformation->getPreProcessor());
-
array_push($modelInfoArray,$this->modelInformation->getValDate());
-
array_push($modelInfoArray,$this->modelInformation->getNativeSchema());
- $sqlString = "(";
- foreach($modelInfoArray as $value) {
- $valueString = (empty($value)) ? 'null' :
"'".addslashes($value)."'";
- $sqlString = $sqlString.$valueString.",";
+
+ public function getModelInformation()
+ {
+ $this->checkArgumentsForRead();
+ $modelTable = self::bimModelTable;
+ $sql = "select * from $modelTable where id=" .
$this->modelId;
+ try
+ {
+ if(is_null($this->db->query($sql, __LINE__,
__FILE__)))
+ {
+ throw new Exception('Query to get model
information was unsuccessful');
+ }
+ if($this->db->num_rows() == 0)
+ {
+ throw new ModelDoesNotExistException();
+ }
+ $this->db->next_record();
+ return
$this->assembleBimModelInfoFromCurrentDatabaseRecord();
+ }
+ catch(Exception $e)
+ {
+ echo "An exception was caught while updating!";
+ throw $e;
+ }
}
- $sqlString = substr($sqlString,0,-1);
- $sqlString = $sqlString.")";
- return $sqlString;*/
- }
-
- public function getModelInformation() {
- $this->checkArgumentsForRead();
- $modelTable = self::bimModelTable;
- $sql = "select * from $modelTable where id=".$this->modelId;
- try {
- if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
- throw new Exception('Query to get model
information was unsuccessful');
- }
- if($this->db->num_rows() == 0) {
- throw new ModelDoesNotExistException();
+
+ private function assembleBimModelInfoFromCurrentDatabaseRecord()
+ {
+ $bimModelInformation = new BimModelInformation();
+ foreach($this->modelInformationMapping as $columnName
=> $methodName)
+ {
+ $cmd = '$bimModelInformation->set' .
$methodName . '($this->db->f(\'' . $columnName . '\'));';
+ eval($cmd);
}
- $this->db->next_record();
- return
$this->assembleBimModelInfoFromCurrentDatabaseRecord();
- } catch (Exception $e) {
- echo "An exception was caught while updating!";
- throw $e;
+ return $bimModelInformation;
}
- }
- private function assembleBimModelInfoFromCurrentDatabaseRecord() {
- $bimModelInformation = new BimModelInformation();
- foreach($this->modelInformationMapping as $columnName =>
$methodName) {
- $cmd =
'$bimModelInformation->set'.$methodName.'($this->db->f(\''.$columnName.'\'));';
- eval($cmd);
+
+ public function setDb(phpgwapi_db_ $db)
+ {
+ $this->db = $db;
}
- return $bimModelInformation;
- }
-
- public function setDb(phpgwapi_db_ $db) {
- $this->db = $db;
- }
- public function setBimModelInformation(BimModelInformation $binfo) {
- $this->modelInformation = $binfo;
- }
- public function getModelId() {
- return $this->modelId;
- }
- public function setModelId(int $id) {
- $this->modelId = $id;
- }
-}
+
+ public function setBimModelInformation(BimModelInformation
$binfo)
+ {
+ $this->modelInformation = $binfo;
+ }
+
+ public function getModelId()
+ {
+ return $this->modelId;
+ }
+
+ public function setModelId(int $id)
+ {
+ $this->modelId = $id;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sobimtype.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sobimtype.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sobimtype.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -4,125 +4,157 @@
* do not add any global variables into this code!
* Any global variables needed should be injected via methods
*/
- interface sobimtype extends sobim {
+
+ interface sobimtype extends sobim
+ {
/*
- * @param string type
- */
- public function getBimObjectType($type);
- /*
- * @param $description max 512char string, may be null
- * @param $name non empty string
- * @throws exception if object type already exists
- * @return int id of new object type
- */
- public function addBimObjectType($name, $description);
-
- public function deleteBimObjectType($name);
-
- public function updateBimObjectTypeDescription($name, $newDescription);
-
+ * @param string type
+ */
+
+ public function getBimObjectType($type);
+ /*
+ * @param $description max 512char string, may be null
+ * @param $name non empty string
+ * @throws exception if object type already exists
+ * @return int id of new object type
+ */
+
+ public function addBimObjectType($name, $description);
+
+ public function deleteBimObjectType($name);
+
+ public function updateBimObjectTypeDescription($name,
$newDescription);
}
-
- class sobimtype_impl implements sobimtype {
-
+
+ class sobimtype_impl implements sobimtype
+ {
/* @var phpgwapi_db_ */
+
private $db;
- public function __construct(& $db) {
- // $this->db = & $GLOBALS['phpgw']->db;
- $this->db = $db;
- }
+ public function __construct(& $db)
+ {
+ // $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = $db;
+ }
/*
- * @return null|BimType
- */
- public function getBimObjectType($type) {
- $resultAlias = 'test_type_count';
- $sql = "SELECT * FROM public.".self::bimTypeTable."
WHERE ".self::bimTypeTable.".name = '".$type."'";
- $q = $this->db->query($sql,__LINE__,__FILE__);
- if(is_null($q)) {
+ * @return null|BimType
+ */
+
+ public function getBimObjectType($type)
+ {
+ $resultAlias = 'test_type_count';
+ $sql = "SELECT * FROM public." . self::bimTypeTable .
" WHERE " . self::bimTypeTable . ".name = '" . $type . "'";
+ $q = $this->db->query($sql, __LINE__, __FILE__);
+ if(is_null($q))
+ {
throw new Exception('Query to get object type
was unsuccessful');
}
- if($this->db->num_rows() == 0) {
+ if($this->db->num_rows() == 0)
+ {
return null;
- } else {
+ }
+ else
+ {
$this->db->next_record();
- return new
BimType($this->db->f('id'),$this->db->f('name'), $this->db->f('description'));
+ return new BimType($this->db->f('id'),
$this->db->f('name'), $this->db->f('description'));
}
- }
-
+ }
/*
- * @return boolean
- * @throws exception if query fails
- */
- public function addBimObjectType($name, $description = null) {
- if($this->getBimObjectType($name) != null) {
- throw new Exception('Type already exists!');
- }
+ * @return boolean
+ * @throws exception if query fails
+ */
- $location_id = $GLOBALS['phpgw']->locations->add($name,
$description ? $description : $name , 'bim');
+ public function addBimObjectType($name, $description = null)
+ {
+ if($this->getBimObjectType($name) != null)
+ {
+ throw new Exception('Type already exists!');
+ }
- if(is_null($description))
- {
- $sql = "INSERT INTO ".self::bimTypeTable."
(location_id, name) VALUES ($location_id, '$name')";
- }
- else
- {
- $description = $this->db->db_addslashes($description);
- $sql = "INSERT INTO ".self::bimTypeTable."
(location_id, name, description) VALUES ($location_id, '$name',
'$description')";
- }
+ $location_id = $GLOBALS['phpgw']->locations->add($name,
$description ? $description : $name, 'bim');
- if(is_null($this->db->query($sql,__LINE__,__FILE__) ))
+ if(is_null($description))
{
+ $sql = "INSERT INTO " . self::bimTypeTable . "
(location_id, name) VALUES ($location_id, '$name')";
+ }
+ else
+ {
+ $description =
$this->db->db_addslashes($description);
+ $sql = "INSERT INTO " . self::bimTypeTable . "
(location_id, name, description) VALUES ($location_id, '$name',
'$description')";
+ }
+
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
throw new Exception("Error adding object
type!");
}
else
{
return true;
}
- }
- /*
- * @return boolean
- */
- public function deleteBimObjectType($name) {
- $sql = "Delete FROM public.".self::bimTypeTable." WHERE
".self::bimTypeTable.".name = '".$name."'";
- if(is_null($this->db->query($sql,__LINE__,__FILE__) )){
+ }
+ /*
+ * @return boolean
+ */
+
+ public function deleteBimObjectType($name)
+ {
+ $sql = "Delete FROM public." . self::bimTypeTable . "
WHERE " . self::bimTypeTable . ".name = '" . $name . "'";
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
throw new Exception("Error deleting object
type!");
- } else {
+ }
+ else
+ {
return true;
}
- }
-
- public function updateBimObjectTypeDescription($name, $newDescription)
{
- $sql = "Update ".self::bimTypeTable." set
description='$newDescription' where name='".$name."'";
- if(is_null($this->db->query($sql,__LINE__,__FILE__) )){
+ }
+
+ public function updateBimObjectTypeDescription($name,
$newDescription)
+ {
+ $sql = "Update " . self::bimTypeTable . " set
description='$newDescription' where name='" . $name . "'";
+ if(is_null($this->db->query($sql, __LINE__, __FILE__)))
+ {
throw new Exception("Error updating description
of object type!");
- } else {
+ }
+ else
+ {
return true;
}
- }
-
+ }
}
-
- class BimType {
- private $id;
- private $name;
- private $description;
- function __construct($id = null, $name = null, $description = null) {
- $this->id = $id;
- $this->name = $name;
- $this->description = $description;
- }
- function getId() {
- return $this->id;
- }
- function getName() {
- return $this->name;
- }
- function getDescription() {
- return $this->description;
- }
- function setId($id) {
- $this->id = $id;
- }
-
- }
+
+ class BimType
+ {
+
+ private $id;
+ private $name;
+ private $description;
+
+ function __construct($id = null, $name = null, $description =
null)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ $this->description = $description;
+ }
+
+ function getId()
+ {
+ return $this->id;
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+
+ function getDescription()
+ {
+ return $this->description;
+ }
+
+ function setId($id)
+ {
+ $this->id = $id;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.soitem.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.soitem.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.soitem.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,187 +1,185 @@
<?php
+ phpgw::import_class('bim.soitem_group');
+ phpgw::import_class('bim.boitem');
-phpgw::import_class('bim.soitem_group');
-phpgw::import_class('bim.boitem');
+ /**
+ * Description of soitem
+ *
+ * @author Espen
+ */
+ class bim_soitem
+ {
- /**
- * Description of soitem
- *
- * @author Espen
- */
- class bim_soitem
- {
- private $db;
- private static $instance;
- public $uicols;
+ private $db;
+ private static $instance;
+ public $uicols;
- private function __construct() {
- $this->db = & $GLOBALS['phpgw']->db;
- }
+ private function __construct()
+ {
+ $this->db = & $GLOBALS['phpgw']->db;
+ }
+ /**
+ * @return bim_soitem
+ */
+ public static function singleton()
+ {
+ if(!isset(self::$instance))
+ {
+ $c = __CLASS__;
+ self::$instance = new $c;
+ }
+ return self::$instance;
+ }
- /**
- * @return bim_soitem
- */
- public static function singleton()
- {
- if (!isset(self::$instance))
- {
- $c = __CLASS__;
- self::$instance = new $c;
- }
- return self::$instance;
- }
+ /**
+ * Retreive any number of items.
+ * @param array $data
+ * @return array Array of zero or more items
+ */
+ public function read(array $data)
+ {
+ // TODO: Use data
+ $start = isset($data['start']) ? $data['start'] : 0;
+ $filter = $data['filter'] ? $data['filter'] : 'none';
+ $query = $data['query'];
+ $sort = $data['sort'] ? $data['sort'] : 'DESC';
+ $order = $data['order'];
+ $cat_id = $data['cat_id'];
+ $allrows = $data['allrows'];
+ $member_id = $data['member_id'] ? $data['member_id'] :
0;
+ $dry_run = $data['dry_run'];
- /**
- * Retreive any number of items.
- * @param array $data
- * @return array Array of zero or more items
- */
- public function read(array $data)
- {
- // TODO: Use data
- $start = isset($data['start']) ? $data['start'] : 0;
- $filter = $data['filter'] ? $data['filter'] : 'none';
- $query = $data['query'];
- $sort = $data['sort'] ? $data['sort'] : 'DESC';
- $order = $data['order'];
- $cat_id = $data['cat_id'];
- $allrows = $data['allrows'];
- $member_id = $data['member_id'] ? $data['member_id'] : 0;
- $dry_run = $data['dry_run'];
+ $uicols = array();
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['statustext'][] = lang('ID');
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
- $uicols = array();
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = lang('ID');
- $uicols['statustext'][] = lang('ID');
- $uicols['datatype'][] = false;
- $uicols['attib_id'][] = false;
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'group';
+ $uicols['descr'][] = 'Gruppe';
+ $uicols['statustext'][] = 'Gruppe';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'group';
- $uicols['descr'][] = 'Gruppe';
- $uicols['statustext'][] = 'Gruppe';
- $uicols['datatype'][] = false;
- $uicols['attib_id'][] = false;
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'location';
+ $uicols['descr'][] = 'Location';
+ $uicols['statustext'][] = 'Location';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'location';
- $uicols['descr'][] = 'Location';
- $uicols['statustext'][] = 'Location';
- $uicols['datatype'][] = false;
- $uicols['attib_id'][] = false;
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'installed';
+ $uicols['descr'][] = 'Installert';
+ $uicols['statustext'][] = 'Installert';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'installed';
- $uicols['descr'][] = 'Installert';
- $uicols['statustext'][] = 'Installert';
- $uicols['datatype'][] = false;
- $uicols['attib_id'][] = false;
+ $this->uicols = $uicols;
- $this->uicols = $uicols;
+ $select_cols = array(
+ 'i.id',
+ 'i.group_id',
+ 'i.location_id',
+ 'i.vendor_id',
+ 'i.installed'
+ );
+ $from_tables = array('fm_item i');
+ $joins = array(
+ //$this->db->left_join.' fm_item_group g ON
i.group_id = g.id',
+ $this->db->left_join . ' fm_vendor v ON
i.vendor_id = v.id'
+ );
+ $where_clauses = array(' WHERE 1=1');
- $select_cols = array(
- 'i.id',
- 'i.group_id',
- 'i.location_id',
- 'i.vendor_id',
- 'i.installed'
- );
- $from_tables = array('fm_item i');
- $joins = array(
- //$this->db->left_join.' fm_item_group g ON i.group_id = g.id',
- $this->db->left_join.' fm_vendor v ON i.vendor_id = v.id'
- );
- $where_clauses = array(' WHERE 1=1');
+ if($specific_item_id)
+ {
+ // FIXME Sanitize input!!
+ $where_clauses[] = "i.id = $specific_item_id";
+ }
- if($specific_item_id) {
- // FIXME Sanitize input!!
- $where_clauses[] = "i.id = $specific_item_id";
- }
+ $sql = 'SELECT ' . implode($select_cols, ', ') .
+ ' FROM ' . implode($from_tables, ', ') .
+ implode($joins, ' ') .
+ implode($where_clauses, ' AND ');
- $sql = 'SELECT ' . implode($select_cols, ', ') .
- ' FROM ' . implode($from_tables, ', ') .
- implode($joins, ' ') .
- implode($where_clauses, ' AND ');
+ $this->db->query($sql);
+ $i = 0;
+ while($this->db->next_record())
+ {
+ $items[$i]['id'] = $this->db->f('id');
+ $items[$i]['group'] = $this->db->f('group_id');
+ $items[$i]['location'] =
$this->db->f('location_id');
+ $items[$i]['vendor'] =
$this->db->f('vendor_id');
+ $items[$i]['installed'] =
$this->db->f('installed');
- $this->db->query($sql);
- $i = 0;
- while($this->db->next_record())
- {
- $items[$i]['id'] = $this->db->f('id');
- $items[$i]['group'] = $this->db->f('group_id');
- $items[$i]['location'] = $this->db->f('location_id');
- $items[$i]['vendor'] = $this->db->f('vendor_id');
- $items[$i]['installed']= $this->db->f('installed');
+ $i++;
+ }
- $i++;
- }
+ return $items;
+ }
- return $items;
- }
+ /**
+ * Creates fully populated objects out of an item array.
+ *
+ * @param array $items Array of items in the same format as
that returned from get_items().
+ * @return mixed Array of item objects og null if failed.
+ */
+ private function populate(array $items)
+ {
+ if(!is_array($items))
+ {
+ return null;
+ }
+ $return_objects = array();
+ $sogroup = bim_sogroup::singleton();
- /**
- * Creates fully populated objects out of an item array.
- *
- * @param array $items Array of items in the same format as that
returned from get_items().
- * @return mixed Array of item objects og null if failed.
- */
- private function populate(array $items)
- {
- if(!is_array($items))
- {
- return null;
- }
+ foreach($items as $item)
+ {
+ $item_obj = new
bim_boitem($items['installed_date']);
+
$item_obj->set_group($sogroup->get($item['group_id']));
- $return_objects = array();
- $sogroup = bim_sogroup::singleton();
+ $return_objects[] = $item_obj;
+ }
- foreach($items as $item)
- {
- $item_obj = new bim_boitem($items['installed_date']);
- $item_obj->set_group($sogroup->get($item['group_id']));
+ return $return_objects;
+ }
- $return_objects[] = $item_obj;
- }
+ /**
+ * Save changes on an item to database or insert a new one if
ID is empty.
+ *
+ * @param bim_boitem $obj
+ */
+ public function save(bim_boitem $obj)
+ {
+ // If item has an ID, do an update, otherwise, do an
insert
+ $ins_or_upd = ($obj->get_id() != null ? 'UPDATE' :
'INSERT INTO');
+ $table = 'fm_item';
+ $cols = array('id', 'group_id', 'location_id',
'vendor_id', 'installed');
+ $values = array($obj->get_id(),
+ $obj->get_group()->get_id(),
+ $obj->get_location_id(),
+ $obj->get_vendor_id(),
+ $obj->get_installed_date());
+ }
- return $return_objects;
- }
+ /**
+ * Get total number of records (rows) in item table
+ *
+ * @return integer No. of records
+ */
+ public function total_records()
+ {
+ $sql = 'SELECT COUNT(id) AS rows FROM fm_item';
-
- /**
- * Save changes on an item to database or insert a new one if ID is
empty.
- *
- * @param bim_boitem $obj
- */
- public function save(bim_boitem $obj)
- {
- // If item has an ID, do an update, otherwise, do an insert
- $ins_or_upd = ($obj->get_id() != null ? 'UPDATE' : 'INSERT INTO');
- $table = 'fm_item';
- $cols = array('id', 'group_id', 'location_id', 'vendor_id',
'installed');
- $values = array($obj->get_id(),
- $obj->get_group()->get_id(),
- $obj->get_location_id(),
- $obj->get_vendor_id(),
- $obj->get_installed_date());
- }
-
-
- /**
- * Get total number of records (rows) in item table
- *
- * @return integer No. of records
- */
- public function total_records()
- {
- $sql = 'SELECT COUNT(id) AS rows FROM fm_item';
-
- $this->db->query($sql);
- // Move pointer to first row
- $this->db->next_record();
- // Get value of 'rows' column
- return (int) $this->db->f('rows');
- }
- }
+ $this->db->query($sql);
+ // Move pointer to first row
+ $this->db->next_record();
+ // Get value of 'rows' column
+ return (int)$this->db->f('rows');
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.soitem_group.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.soitem_group.inc.php 2016-01-05
08:28:44 UTC (rev 14620)
+++ branches/dev-syncromind/bim/inc/class.soitem_group.inc.php 2016-01-05
08:48:25 UTC (rev 14621)
@@ -1,109 +1,111 @@
<?php
- /**
- * Description of sogroup
- *
- * @author Espen
- */
- class bim_soitem_group {
- private $db;
- private static $instance;
+ /**
+ * Description of sogroup
+ *
+ * @author Espen
+ */
+ class bim_soitem_group
+ {
- private function __construct() {
- $this->db = & $GLOBALS['phpgw']->db;
- }
+ private $db;
+ private static $instance;
+ private function __construct()
+ {
+ $this->db = & $GLOBALS['phpgw']->db;
+ }
- /**
- * @return bim_sogroup
- */
- public static function singleton()
- {
- if (!isset(self::$instance))
- {
- $c = __CLASS__;
- self::$instance = new $c;
- }
- return self::$instance;
- }
+ /**
+ * @return bim_sogroup
+ */
+ public static function singleton()
+ {
+ if(!isset(self::$instance))
+ {
+ $c = __CLASS__;
+ self::$instance = new $c;
+ }
+ return self::$instance;
+ }
- /**
- * Retreive any number of groups.
- * @param array $data
- * @return array Array of zero or more groups
- */
- public function read(array $data)
- {
- $start = isset($data['start']) ? $data['start'] : 0;
- $filter = isset($data['filter']) ? $data['filter'] : 'none';
- $query = $data['query'];
- $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
- $order = $data['order'];
- $allrows = $data['allrows'];
- $dry_run = $data['dry_run'];
+ /**
+ * Retreive any number of groups.
+ * @param array $data
+ * @return array Array of zero or more groups
+ */
+ public function read(array $data)
+ {
+ $start = isset($data['start']) ? $data['start'] : 0;
+ $filter = isset($data['filter']) ? $data['filter'] :
'none';
+ $query = $data['query'];
+ $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
+ $order = $data['order'];
+ $allrows = $data['allrows'];
+ $dry_run = $data['dry_run'];
- $ret = array();
+ $ret = array();
- $entity_table = 'fm_item_group';
- $cols = array($entity_table.'.*');
- $where_clauses = array(' WHERE 1=1');
- $joins = array();
+ $entity_table = 'fm_item_group';
+ $cols = array($entity_table . '.*');
+ $where_clauses = array(' WHERE 1=1');
+ $joins = array();
- $sql = 'SELECT ' . implode($cols, ', ') .
- " FROM $entity_table ".
- implode($joins, ' ') .
- implode($where_clauses, ' AND ');
+ $sql = 'SELECT ' . implode($cols, ', ') .
+ " FROM $entity_table " .
+ implode($joins, ' ') .
+ implode($where_clauses, ' AND ');
- $this->db->query($sql);
- $i = 0;
- while($this->db->next_record()) {
- $items[$i]['id'] = $this->db->f('id');
- $items[$i]['name'] = $this->db->f('name');
- $items[$i]['ngno'] = $this->db->f('nat_group_no');
- $items[$i]['bpn'] = $this->db->f('bpn');
- $items[$i]['parent'] = $this->db->f('parent_group');
- $items[$i]['catalog_id']= $this->db->f('catalog_id');
+ $this->db->query($sql);
+ $i = 0;
+ while($this->db->next_record())
+ {
+ $items[$i]['id'] = $this->db->f('id');
+ $items[$i]['name'] = $this->db->f('name');
+ $items[$i]['ngno'] =
$this->db->f('nat_group_no');
+ $items[$i]['bpn'] = $this->db->f('bpn');
+ $items[$i]['parent'] =
$this->db->f('parent_group');
+ $items[$i]['catalog_id'] =
$this->db->f('catalog_id');
- $i++;
- }
+ $i++;
+ }
- return $items;
- }
+ return $items;
+ }
- // TODO
- public function read_single($id)
- {
-
- }
-
+ // TODO
+ public function read_single($id)
+ {
+
+ }
+ /**
+ * Creates fully populated objects out of an item array.
+ *
+ * @param array $items Array of items in the same format as
that returned from get_items().
+ * @return mixed Array of item objects og null if failed.
+ */
+ public function populate(array $groups)
+ {
+ if(!is_array($groups))
+ {
+ return null;
+ }
- /**
- * Creates fully populated objects out of an item array.
- *
- * @param array $items Array of items in the same format as that
returned from get_items().
- * @return mixed Array of item objects og null if failed.
- */
- public function populate(array $groups) {
- if(!is_array($groups)) {
- return null;
- }
+ $return_objects = array();
+ $socatalog = bim_socatalog::get_instance();
- $return_objects = array();
- $socatalog = bim_socatalog::get_instance();
+ foreach($groups as $group)
+ {
+ $group_obj = new bim_bogroup();
+ $group_obj->set_bpn($group['bpn']);
+ $group_obj->set_name($group['name']);
+ $group_obj->set_nat_group_no($group['ngno']);
+
$group_obj->set_catalog($socatalog->get($group['catalog_id']));
- foreach($groups as $group) {
- $group_obj = new bim_bogroup();
- $group_obj->set_bpn($group['bpn']);
- $group_obj->set_name($group['name']);
- $group_obj->set_nat_group_no($group['ngno']);
- $group_obj->set_catalog($socatalog->get($group['catalog_id']));
+ $return_objects[] = $group_obj;
+ }
- $return_objects[] = $group_obj;
- }
-
- return $return_objects;
- }
-
-
- }
+ return $return_objects;
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/bim/inc/class.sovfs.inc.php
===================================================================
--- branches/dev-syncromind/bim/inc/class.sovfs.inc.php 2016-01-05 08:28:44 UTC
(rev 14620)
+++ branches/dev-syncromind/bim/inc/class.sovfs.inc.php 2016-01-05 08:48:25 UTC
(rev 14621)
@@ -1,41 +1,57 @@
<?php
-/*
- * Class that interacts with the VFS system in portico
- */
-phpgw::import_class('bim.bimExceptions');
/*
+ * Class that interacts with the VFS system in portico
+ */
+ phpgw::import_class('bim.bimExceptions');
+ /*
* Interface for communicating with Portico estate's virtual file system
*/
- interface sovfs {
+
+ interface sovfs
+ {
+
public function addFileToVfs();
+
public function getFileInformation();
+
public function getFileFromVfs();
+
public function removeFileFromVfs();
+
public function checkIfFileExists();
- public function retrieveVfsFileId() ;
+
+ public function retrieveVfsFileId();
+
public function setFilename($filename);
+
public function setFileNameWithFullPath($fileNameWithFullPath);
/*
* Arguments that needed to be set: Filename and Submodule
* @return the absolute file name and path of the VFS file in
the current filesystem
*/
+
public function getAbsolutePathOfVfsFile();
/*
* Submodule is in effect the subdirectory under /property that
the file is put into
*/
+
public function setSubModule($subModule);
+
public function getSubModule();
}
-
- class sovfs_impl implements sovfs {
+
+ class sovfs_impl implements sovfs
+ {
/* @var $bofiles property_bofiles */
+
private $bofiles;
private $filename;
private $fileNameWithFullPath;
private $subModule;
public $debug = false;
-
- public function __construct($filename = null,
$fileNameWithFullPath = null, $subModule = null){
+
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14621] formatting,
Sigurd Nes <=