2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* InputDocument.php
|
2012-10-19 11:45:05 -04:00
|
|
|
*
|
|
|
|
|
* @package workflow.engine.classes.model
|
|
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
* ProcessMaker Open Source Edition
|
2011-01-31 14:14:55 +00:00
|
|
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
2012-10-19 11:45:05 -04:00
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 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
|
2012-10-19 11:45:05 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2012-10-19 11:45:05 -04:00
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-19 11:45:05 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
2010-12-02 23:34:41 +00:00
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
2012-10-19 11:45:05 -04:00
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require_once 'classes/model/om/BaseInputDocument.php';
|
|
|
|
|
require_once 'classes/model/Content.php';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skeleton subclass for representing a row from the 'INPUT_DOCUMENT' table.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* You should add additional methods to this class to meet the
|
2012-10-19 11:45:05 -04:00
|
|
|
* application requirements. This class will only be generated as
|
2010-12-02 23:34:41 +00:00
|
|
|
* long as it does not already exist in the input directory.
|
|
|
|
|
*
|
2012-10-19 11:45:05 -04:00
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
2012-10-19 11:45:05 -04:00
|
|
|
class InputDocument extends BaseInputDocument
|
|
|
|
|
{
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* This value goes in the content table
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $inp_doc_title = '';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* This value goes in the content table
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $inp_doc_description = '';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/*
|
|
|
|
|
* Load the application document registry
|
|
|
|
|
* @param string $sAppDocUid
|
|
|
|
|
* @return variant
|
|
|
|
|
*/
|
|
|
|
|
public function load ($sInpDocUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
|
|
|
|
if (! is_null( $oInputDocument )) {
|
|
|
|
|
$aFields = $oInputDocument->toArray( BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
|
|
|
|
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
|
|
|
|
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
return $aFields;
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
public function getByUid ($sInpDocUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
|
|
|
|
if (is_null( $oInputDocument )) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
$aFields = $oInputDocument->toArray( BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
|
|
|
|
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
|
|
|
|
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
return $aFields;
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Create the application document registry
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return string
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function create ($aData)
|
|
|
|
|
{
|
|
|
|
|
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
if (isset( $aData['INP_DOC_UID'] ) && $aData['INP_DOC_UID'] == '') {
|
|
|
|
|
unset( $aData['INP_DOC_UID'] );
|
|
|
|
|
}
|
|
|
|
|
if (! isset( $aData['INP_DOC_UID'] )) {
|
|
|
|
|
$aData['INP_DOC_UID'] = G::generateUniqueID();
|
|
|
|
|
}
|
|
|
|
|
$oInputDocument = new InputDocument();
|
|
|
|
|
$oInputDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
if ($oInputDocument->validate()) {
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
if (isset( $aData['INP_DOC_TITLE'] )) {
|
|
|
|
|
$oInputDocument->setInpDocTitle( $aData['INP_DOC_TITLE'] );
|
|
|
|
|
}
|
|
|
|
|
if (isset( $aData['INP_DOC_DESCRIPTION'] )) {
|
|
|
|
|
$oInputDocument->setInpDocDescription( $aData['INP_DOC_DESCRIPTION'] );
|
|
|
|
|
}
|
|
|
|
|
$iResult = $oInputDocument->save();
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
return $aData['INP_DOC_UID'];
|
|
|
|
|
} else {
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
$aValidationFailures = $oInputDocument->getValidationFailures();
|
|
|
|
|
foreach ($aValidationFailures as $oValidationFailure) {
|
|
|
|
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
|
|
|
|
}
|
|
|
|
|
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
throw ($oError);
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Update the application document registry
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return string
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function update ($aData)
|
|
|
|
|
{
|
|
|
|
|
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$oInputDocument = InputDocumentPeer::retrieveByPK( $aData['INP_DOC_UID'] );
|
|
|
|
|
if (! is_null( $oInputDocument )) {
|
|
|
|
|
$oInputDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
if ($oInputDocument->validate()) {
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
if (isset( $aData['INP_DOC_TITLE'] )) {
|
|
|
|
|
$oInputDocument->setInpDocTitle( $aData['INP_DOC_TITLE'] );
|
|
|
|
|
}
|
|
|
|
|
if (isset( $aData['INP_DOC_DESCRIPTION'] )) {
|
|
|
|
|
$oInputDocument->setInpDocDescription( $aData['INP_DOC_DESCRIPTION'] );
|
|
|
|
|
}
|
|
|
|
|
$iResult = $oInputDocument->save();
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
return $iResult;
|
|
|
|
|
} else {
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
$aValidationFailures = $oInputDocument->getValidationFailures();
|
|
|
|
|
foreach ($aValidationFailures as $oValidationFailure) {
|
|
|
|
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
|
|
|
|
}
|
|
|
|
|
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Remove the application document registry
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return string
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function remove ($sInpDocUid)
|
|
|
|
|
{
|
|
|
|
|
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
|
|
|
|
if (! is_null( $oInputDocument )) {
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
Content::removeContent( 'INP_DOC_TITLE', '', $oInputDocument->getInpDocUid() );
|
|
|
|
|
Content::removeContent( 'INP_DOC_DESCRIPTION', '', $oInputDocument->getInpDocUid() );
|
|
|
|
|
$iResult = $oInputDocument->delete();
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
return $iResult;
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( 'This row doesn\'t exist!' ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Get the [inp_doc_title] column value.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getInpDocTitle ()
|
|
|
|
|
{
|
|
|
|
|
if ($this->inp_doc_title == '') {
|
|
|
|
|
try {
|
|
|
|
|
$this->inp_doc_title = Content::load( 'INP_DOC_TITLE', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->inp_doc_title;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Set the [inp_doc_title] column value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $sValue new value
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setInpDocTitle ($sValue)
|
|
|
|
|
{
|
|
|
|
|
if ($sValue !== null && ! is_string( $sValue )) {
|
|
|
|
|
$sValue = (string) $sValue;
|
|
|
|
|
}
|
|
|
|
|
if ($this->inp_doc_title !== $sValue || $sValue === '') {
|
|
|
|
|
try {
|
|
|
|
|
$this->inp_doc_title = $sValue;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
$iResult = Content::addContent( 'INP_DOC_TITLE', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->inp_doc_title );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$this->inp_doc_title = '';
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 11:45:05 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the [inp_doc_comment] column value.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getInpDocDescription ()
|
|
|
|
|
{
|
|
|
|
|
if ($this->inp_doc_description == '') {
|
|
|
|
|
try {
|
|
|
|
|
$this->inp_doc_description = Content::load( 'INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->inp_doc_description;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
/**
|
|
|
|
|
* Set the [inp_doc_comment] column value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $sValue new value
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setInpDocDescription ($sValue)
|
|
|
|
|
{
|
|
|
|
|
if ($sValue !== null && ! is_string( $sValue )) {
|
|
|
|
|
$sValue = (string) $sValue;
|
|
|
|
|
}
|
|
|
|
|
if ($this->inp_doc_description !== $sValue || $sValue === '') {
|
|
|
|
|
try {
|
|
|
|
|
$this->inp_doc_description = $sValue;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-19 11:45:05 -04:00
|
|
|
$iResult = Content::addContent( 'INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->inp_doc_description );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$this->inp_doc_description = '';
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 11:45:05 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* verify if Input row specified in [DynUid] exists.
|
|
|
|
|
*
|
|
|
|
|
* @param string $sUid the uid of the Prolication
|
|
|
|
|
*/
|
|
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function InputExists ($sUid)
|
2012-10-19 11:45:05 -04:00
|
|
|
{
|
|
|
|
|
$con = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$oObj = InputDocumentPeer::retrieveByPk( $sUid );
|
|
|
|
|
if (is_object( $oObj ) && get_class( $oObj ) == 'InputDocument') {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 11:45:05 -04:00
|
|
|
}
|
|
|
|
|
// InputDocument
|
2010-12-02 23:34:41 +00:00
|
|
|
|