<?php

foreach (Attribute::LoadAll() as $objAttribute) {
    $objNodes = QueryNode::QueryArray(QQ::AndCondition(QQ::Equal(QQN::QueryNode()->QueryNodeTypeId, QueryNodeType::AttributeNode), QQ::Equal(QQN::QueryNode()->NodeDetail, $objAttribute->Id)));
    if (count($objNodes)) {
        foreach ($objNodes as $objQueryNode) {
            $objQueryNode->Name = $objAttribute->Name;
            $objQueryNode->QcodoQueryNode = null;
            $objQueryNode->QueryNodeTypeId = QueryNodeType::AttributeNode;
            $objQueryNode->QueryDataTypeId = AttributeDataType::$QueryDataTypeArray[$objAttribute->AttributeDataTypeId];
            $objQueryNode->NodeDetail = $objAttribute->Id;
            $objQueryNode->Save();
        }
    } else {
        $objQueryNode = new QueryNode();
        $objQueryNode->Name = $objAttribute->Name;
        $objQueryNode->QcodoQueryNode = null;
        $objQueryNode->QueryNodeTypeId = QueryNodeType::AttributeNode;
        $objQueryNode->QueryDataTypeId = AttributeDataType::$QueryDataTypeArray[$objAttribute->AttributeDataTypeId];
        $objQueryNode->NodeDetail = $objAttribute->Id;
        $objQueryNode->Save();
    }
}
Exemplo n.º 2
0
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this QueryNodeMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing QueryNode object creation - defaults to CreateOrEdit
  * @return QueryNodeMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objQueryNode = QueryNode::Load($intId);
         // QueryNode was found -- return it!
         if ($objQueryNode) {
             return new QueryNodeMetaControl($objParentObject, $objQueryNode);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a QueryNode object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new QueryNodeMetaControl($objParentObject, new QueryNode());
 }
Exemplo n.º 3
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, QueryNode::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Exemplo n.º 4
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSearchQuery) {
         $objObject->objSearchQuery = SearchQuery::GetSoapObjectFromObject($objObject->objSearchQuery, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSearchQueryId = null;
         }
     }
     if ($objObject->objOrQueryCondition) {
         $objObject->objOrQueryCondition = QueryCondition::GetSoapObjectFromObject($objObject->objOrQueryCondition, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intOrQueryConditionId = null;
         }
     }
     if ($objObject->objQueryOperation) {
         $objObject->objQueryOperation = QueryOperation::GetSoapObjectFromObject($objObject->objQueryOperation, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryOperationId = null;
         }
     }
     if ($objObject->objQueryNode) {
         $objObject->objQueryNode = QueryNode::GetSoapObjectFromObject($objObject->objQueryNode, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryNodeId = null;
         }
     }
     return $objObject;
 }
 /**
  * Refresh this MetaControl with Data from the local QueryCondition object.
  * @param boolean $blnReload reload QueryCondition from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objQueryCondition->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objQueryCondition->Id;
         }
     }
     if ($this->lstSearchQuery) {
         $this->lstSearchQuery->RemoveAllItems();
         $this->lstSearchQuery->AddItem(QApplication::Translate('- Select One -'), null);
         $objSearchQueryArray = SearchQuery::LoadAll();
         if ($objSearchQueryArray) {
             foreach ($objSearchQueryArray as $objSearchQuery) {
                 $objListItem = new QListItem($objSearchQuery->__toString(), $objSearchQuery->Id);
                 if ($this->objQueryCondition->SearchQuery && $this->objQueryCondition->SearchQuery->Id == $objSearchQuery->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSearchQuery->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSearchQueryId) {
         $this->lblSearchQueryId->Text = $this->objQueryCondition->SearchQuery ? $this->objQueryCondition->SearchQuery->__toString() : null;
     }
     if ($this->lstOrQueryCondition) {
         $this->lstOrQueryCondition->RemoveAllItems();
         $this->lstOrQueryCondition->AddItem(QApplication::Translate('- Select One -'), null);
         $objOrQueryConditionArray = QueryCondition::LoadAll();
         if ($objOrQueryConditionArray) {
             foreach ($objOrQueryConditionArray as $objOrQueryCondition) {
                 $objListItem = new QListItem($objOrQueryCondition->__toString(), $objOrQueryCondition->Id);
                 if ($this->objQueryCondition->OrQueryCondition && $this->objQueryCondition->OrQueryCondition->Id == $objOrQueryCondition->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstOrQueryCondition->AddItem($objListItem);
             }
         }
     }
     if ($this->lblOrQueryConditionId) {
         $this->lblOrQueryConditionId->Text = $this->objQueryCondition->OrQueryCondition ? $this->objQueryCondition->OrQueryCondition->__toString() : null;
     }
     if ($this->lstQueryOperation) {
         $this->lstQueryOperation->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstQueryOperation->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objQueryOperationArray = QueryOperation::LoadAll();
         if ($objQueryOperationArray) {
             foreach ($objQueryOperationArray as $objQueryOperation) {
                 $objListItem = new QListItem($objQueryOperation->__toString(), $objQueryOperation->Id);
                 if ($this->objQueryCondition->QueryOperation && $this->objQueryCondition->QueryOperation->Id == $objQueryOperation->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryOperation->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryOperationId) {
         $this->lblQueryOperationId->Text = $this->objQueryCondition->QueryOperation ? $this->objQueryCondition->QueryOperation->__toString() : null;
     }
     if ($this->lstQueryNode) {
         $this->lstQueryNode->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstQueryNode->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objQueryNodeArray = QueryNode::LoadAll();
         if ($objQueryNodeArray) {
             foreach ($objQueryNodeArray as $objQueryNode) {
                 $objListItem = new QListItem($objQueryNode->__toString(), $objQueryNode->Id);
                 if ($this->objQueryCondition->QueryNode && $this->objQueryCondition->QueryNode->Id == $objQueryNode->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryNode->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryNodeId) {
         $this->lblQueryNodeId->Text = $this->objQueryCondition->QueryNode ? $this->objQueryCondition->QueryNode->__toString() : null;
     }
     if ($this->txtValue) {
         $this->txtValue->Text = $this->objQueryCondition->Value;
     }
     if ($this->lblValue) {
         $this->lblValue->Text = $this->objQueryCondition->Value;
     }
     if ($this->lstQueryConditionAsOr) {
         $this->lstQueryConditionAsOr->RemoveAllItems();
         $this->lstQueryConditionAsOr->AddItem(QApplication::Translate('- Select One -'), null);
         $objQueryConditionArray = QueryCondition::LoadAll();
         if ($objQueryConditionArray) {
             foreach ($objQueryConditionArray as $objQueryCondition) {
                 $objListItem = new QListItem($objQueryCondition->__toString(), $objQueryCondition->Id);
                 if ($objQueryCondition->OrQueryConditionId == $this->objQueryCondition->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryConditionAsOr->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryConditionAsOr) {
         $this->lblQueryConditionAsOr->Text = $this->objQueryCondition->QueryConditionAsOr ? $this->objQueryCondition->QueryConditionAsOr->__toString() : null;
     }
 }
Exemplo n.º 6
0
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = QueryNode::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from QueryNode, given the clauses above
     $this->DataSource = QueryNode::QueryArray($objCondition, $objClauses);
 }
Exemplo n.º 7
0
 public function lstOperation_Refresh($intIndex, $blnCreating)
 {
     $lstNode = $this->objForm->GetControl('lstNode' . $intIndex);
     $lstOperation = $this->objForm->GetControl('lstOperation' . $intIndex);
     $lstOperation->RemoveAllItems();
     if (!$lstNode->SelectedValue) {
         $lstOperation->AddItem('--');
         $lstOperation->SelectedIndex = 0;
         $lstOperation->Enabled = false;
         $lstOperation->Required = false;
     } else {
         $objNode = QueryNode::Load($lstNode->SelectedValue);
         $lstOperation->Enabled = true;
         $lstOperation->Required = true;
         $lstOperation->AddItem('- None -');
         foreach ($this->objOperationArray as $objQueryOperation) {
             if ($objQueryOperation->QueryDataTypeBitmap & $objNode->QueryDataTypeId) {
                 $lstOperation->AddItem($objQueryOperation->Name, $objQueryOperation->Id, $blnCreating && array_key_exists($intIndex, $this->objQueryConditionArray) && $this->objQueryConditionArray[$intIndex]->QueryOperationId == $objQueryOperation->Id);
             }
         }
     }
 }