/**
  *
  * @param string $type
  * @param StdObject $stdObject
  * @return ssrs Object
  */
 protected function FromStdObject_Base($type, $stdObject)
 {
     $object;
     if ($type != 'self') {
         $class = new ReflectionClass($type);
         $object = $class->newInstance();
     } else {
         $type = get_class($this);
         $class = new ReflectionClass($type);
         $object = $this;
     }
     $properties = $class->getProperties();
     foreach ($properties as $rawProperty) {
         $propertyName = $rawProperty->name;
         $property = new ReflectionProperty($object, $propertyName);
         $attributes = Utility::getAttributes($property);
         $value = null;
         switch (SSRSTypeFactory::GetType($attributes['type'])) {
             case 'basic':
                 $value = self::EnumerateBasicObject($stdObject, $propertyName, $attributes);
                 break;
             case 'ssrs':
                 $value = self::EnumerateSSRSObject($stdObject, $propertyName, $attributes);
                 break;
             case 'unknown':
                 throw new PReportException("", "Exception: Unknown_Type:" . $attributes['type']);
                 break;
         }
         $property->setValue($object, $value);
     }
     $object->Initialize();
     return $object;
 }
 protected function GetDevInfoXML_Base($object)
 {
     $retXML = '<DeviceInfo>';
     $className = get_class($object);
     $class = new ReflectionClass($className);
     $properties = $class->getProperties();
     foreach ($properties as $rawProperty) {
         $propertyName = $rawProperty->name;
         $property = new ReflectionProperty($object, $propertyName);
         $attributes = Utility::getAttributes($property);
         if (array_key_exists('xml', $attributes) && null != ($value = $property->getValue($object))) {
             $retXML = $retXML . '<' . $attributes['xml'] . '>' . $value . '</' . $attributes['xml'] . '>';
         }
     }
     $retXML = $retXML . '</DeviceInfo>';
     return $retXML;
 }
 /**
  * Fucntion to display result of query.
  */
 protected function displayEntityData()
 {
     $this->_query = str_replace("\\'", "'", $this->_query);
     $queryToRun = $this->_query;
     $pagingSection = '<table border="0" align="center" CELLSPACING="15">';
     $nextSkip = null;
     $canPage = false;
     if ($this->_enablePaging && (isset($_REQUEST['pagingAllowed']) && $_REQUEST['pagingAllowed'] == 'true')) {
         $canPage = true;
         $skip = 0;
         if (isset($_REQUEST['skip'])) {
             $skip = $_REQUEST['skip'];
         }
         $parts = parse_url($queryToRun);
         if (isset($parts['query'])) {
             $queryToRun .= '&$top=' . $this->_pageSize . '&$skip=' . $skip;
         } else {
             $queryToRun .= '?$top=' . $this->_pageSize . '&$skip=' . $skip;
         }
         $nextSkip = $skip + $this->_pageSize;
         if ($nextSkip != $this->_pageSize) {
             $prev = $skip - $this->_pageSize;
             $pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $prev . '&pagingAllowed=true' . "\">Prev</a></td>";
         }
     }
     $response = $this->_proxyObject->Execute($queryToRun);
     $resultSet = $response->Result;
     echo "<br><br><table style=\"border: thin solid #C0C0C0;\" border=\"1\">";
     if (count($resultSet) > 0) {
         $propertyArray = WCFDataServicesEntity::getProperties($resultSet[0]);
         $this->displayHeader($propertyArray, $resultSet[0]);
         foreach ($resultSet as $result) {
             echo "<tr style=\"font-family: Calibri; " . "background-color: #CCFFFF\">";
             WCFDataServicesEntity::getDetailButtonText($result);
             foreach ($propertyArray as $property) {
                 $prop = new ReflectionProperty($result, $property);
                 $propertyAttributes = Utility::getAttributes($prop);
                 if ($propertyAttributes['Type'] == 'NavigationProperty') {
                     $pagingAllowed = 'pagingAllowed=true';
                     $relationShip = $this->_proxyObject->GetRelationShip($propertyAttributes["Relationship"], $propertyAttributes["ToRole"]);
                     if ($relationShip != '*') {
                         $pagingAllowed = 'pagingAllowed=false';
                     }
                     $skip = null;
                     if (isset($_REQUEST['skip'])) {
                         $skip = '&skip=' . $_REQUEST['skip'];
                     }
                     $pagingAllowedWhileAttaching = null;
                     if (isset($_GET['pagingAllowed'])) {
                         $pagingAllowedWhileAttaching = '&pagingAllowed=' . $_GET['pagingAllowed'];
                     }
                     echo "<td>";
                     $relatedLinks = $result->getRelatedLinks();
                     $finalQuery = $relatedLinks[$property];
                     $finalQuery = str_replace("%20", '', $finalQuery);
                     echo "<a href=\"" . $this->_containerScriptName . "?query=" . $finalQuery . '&' . $pagingAllowed . $skip . "&serviceUri=" . $this->_uri . "\">" . $property . "</a>";
                     echo "<br><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . $pagingAllowedWhileAttaching . $skip . "&serviceUri=" . $this->_uri . "&Type=" . $property . "&AttachTo=" . $finalQuery . "\">  Add Link </a>";
                     echo "</td>";
                 } else {
                     $propertyAttributes = Utility::getAttributes($prop);
                     if (isset($propertyAttributes['EdmType']) && ($index = strpos($propertyAttributes['EdmType'], 'Edm.')) !== 0) {
                         $value = $prop->getValue($result);
                         $type = ClientType::Create(get_class($value));
                         $nonEpmProperties = $type->getRawNonEPMProperties(true);
                         echo '<td><table style="border: thin solid #C0C0C0;" border="1">';
                         foreach ($nonEpmProperties as $nonEpmProperty) {
                             $propertyName = $nonEpmProperty->getName();
                             $refProperty = new ReflectionProperty($value, $propertyName);
                             $propertyValue = $refProperty->getValue($value);
                             echo '<tr><td>';
                             echo $propertyValue;
                             echo '</td></tr>';
                         }
                         echo '</table></td>';
                     } else {
                         if (Utility::ContainAttribute($prop->getDocComment(), 'Binary')) {
                             // TODO: Display image in the cell
                             echo "<td>Image</td>";
                         } else {
                             $value = $prop->getValue($result);
                             if ($value == '') {
                                 $value = 'null';
                             }
                             echo "<td>" . $value . "</td>";
                         }
                     }
                 }
             }
             echo "</tr>";
         }
         if ($canPage) {
             $pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $nextSkip . '&pagingAllowed=true' . "\">Next</a></td><tr/></table>";
         }
     }
     if ($canPage) {
         echo $pagingSection;
     }
     echo "</table><br><br>";
 }
Example #4
0
 /**
  *
  * @param <string> $type
  * Constructor
  */
 public function ClientType($type)
 {
     $this->_attributes = array();
     $this->_properties = array();
     $this->_navigationProperties = array();
     $this->_sortedEPMProperties = array();
     $targetPathToCount = array();
     try {
         $rClass = new ReflectionClass($type);
         $this->_hasEPM = false;
         $this->_attributes = Utility::getAttributes($rClass);
         $sourceProperty = null;
         if (array_key_exists('FC_SourcePath', $this->_attributes)) {
             $this->_hasEPM = true;
             $sourceProperty = $this->_attributes['FC_SourcePath'];
         }
         $properties = $rClass->getProperties();
         foreach ($properties as $property) {
             if ($property->isPublic()) {
                 $attributes = Utility::getAttributes($property);
                 $propertyName = $property->name;
                 if ($sourceProperty != null && $sourceProperty == $propertyName) {
                     ValidateEPMAttributes($this->_attributes, $attributes, $sourceProperty, false);
                 }
                 if (isset($attributes['Type']) && $attributes['Type'] == 'EntityProperty') {
                     $propertyObj = new Property($propertyName, $attributes);
                     $this->_properties[$propertyName] = $propertyObj;
                     if ($propertyObj->hasEPM($syn)) {
                         $this->_hasEPM = true;
                         $attrs = $propertyObj->getAttributes();
                         if ($syn) {
                             $targetPath = SyndicationItemProperty::GetSyndicationItemPathNoNS($attrs['FC_TargetPath']);
                         } else {
                             $targetPath = $attrs['FC_TargetPathNS'];
                             if (isset($attrs['NodeAttribute'])) {
                                 $targetPath .= '/@' . $attrs['NodeAttribute'];
                             }
                         }
                         $targetPathToCount[$targetPath] = substr_count($targetPath, "/");
                     }
                 } else {
                     if (isset($attributes['Type']) && $attributes['Type'] == 'NavigationProperty') {
                         $this->_navigationProperties[$propertyName] = new Property($propertyName, $attributes);
                     }
                 }
             }
         }
         asort($targetPathToCount);
         $properties = $this->_properties;
         foreach ($targetPathToCount as $key => $value) {
             foreach ($properties as $property) {
                 $syn = false;
                 $targetPath = null;
                 if ($property->hasEPM($syn)) {
                     $attrs = $property->getAttributes();
                     if ($syn) {
                         $targetPath = SyndicationItemProperty::GetSyndicationItemPathNoNS($attrs['FC_TargetPath']);
                     } else {
                         $targetPath = $attrs['FC_TargetPathNS'];
                         if (isset($attrs['NodeAttribute'])) {
                             $targetPath .= '/@' . $attrs['NodeAttribute'];
                         }
                     }
                     if ($key == $targetPath) {
                         $this->_sortedEPMProperties[] = $property;
                     }
                 }
             }
         }
     } catch (ReflectionException $exception) {
         throw new InvalidOperation('ReflectionException in ClientType constructor');
     }
 }
Example #5
0
 /**
  * To get HTTP Verb to be used for a binding based on the state of the
  * RelatedEnd object holding the relationship.
  *
  * @param RelatedEnd $binding
  * @return HttpVerb
  */
 public function GetBindingHttpMethod($binding)
 {
     $property = new ReflectionProperty($binding->GetSourceResource(), $binding->GetSourceProperty());
     $attributes = Utility::getAttributes($property);
     $relationShip = $this->_context->GetRelationShip($attributes["Relationship"], $attributes["ToRole"]);
     //SetLink
     if ($relationShip == '0..1' || $relationShip == '1') {
         //SetLink with target null
         if ($binding->GetTargetResource() == null) {
             return HttpVerb::DELETE;
         }
         return HttpVerb::PUT;
     }
     //DeleteLink
     if (EntityStates::Deleted == $binding->State) {
         return HttpVerb::DELETE;
     }
     //AddLink
     return HttpVerb::POST;
 }
Example #6
0
 /**
  * To check whether deleteing a link between $relatedEnd::SourceResource and
  * $relatedEnd::TargetResource is valid based their current states.
  * [Note: Do not call this function from your application, it is used internally]
  *
  * @param $relatedEnd The RelatedEnd
  * @throws InvalidOperation
  */
 protected function ValidateDeleteLink($relatedEnd)
 {
     $sourceObject = $relatedEnd->GetSourceResource();
     $sourceProperty = $relatedEnd->GetSourceProperty();
     $targetObject = $relatedEnd->GetTargetResource();
     $sourceResourceBox = null;
     if (!$this->ObjectToResource->TryGetValue($sourceObject, $sourceResourceBox)) {
         throw new InvalidOperation(Resource::EntityNotContained, Resource::EntityNotContained_Details);
     }
     $targetResourceBox = null;
     if (!$this->ObjectToResource->TryGetValue($targetObject, $targetResourceBox)) {
         throw new InvalidOperation(Resource::EntityNotContained, Resource::EntityNotContained_Details);
     }
     try {
         $property = new ReflectionProperty($sourceObject, $sourceProperty);
     } catch (ReflectionException $ex) {
         throw new InvalidOperation(Resource::NoPropertyForTargetObject, sprintf(Resource::NoPropertyForTargetObject_Details, $sourceProperty));
     }
     $attributes = Utility::getAttributes($property);
     if (!isset($attributes["Relationship"]) || !isset($attributes["ToRole"]) || !isset($attributes["FromRole"]) || !isset($attributes["Type"])) {
         throw new InvalidOperation(Resource::NoRelationBetweenObjects, null);
     }
     if ($attributes["Type"] != "NavigationProperty") {
         throw new InvalidOperation(Resource::RelationNotRefOrCollection, sprintf(Resource::RelationNotRefOrCollection_Details, $sourceProperty));
     }
     $relationShip = $this->GetRelationShip($attributes["Relationship"], $attributes["ToRole"]);
     if ($relationShip != '*') {
         throw new InvalidOperation(sprintf(Resource::AddLinkCollectionOnly, $sourceProperty), Resource::AddLinkCollectionOnly_Details);
     }
 }