Ejemplo n.º 1
0
 /**
  * Retrieve a single metadata object by object id and type.
  *
  * @param      int $metadataProfileId
  * @param      int $objectType
  * @param      string $objectId
  * @param      PropelPDO $con the connection to use
  * @return     Metadata
  */
 public static function retrieveByObject($metadataProfileId, $objectType, $objectId, PropelPDO $con = null)
 {
     $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId, $con);
     if (!$metadataProfile) {
         return null;
     }
     $criteria = new Criteria();
     $criteria->add(MetadataPeer::METADATA_PROFILE_ID, $metadataProfileId);
     $criteria->add(MetadataPeer::OBJECT_TYPE, $objectType);
     $criteria->add(MetadataPeer::OBJECT_ID, $objectId);
     return MetadataPeer::doSelectOne($criteria, $con);
 }
Ejemplo n.º 2
0
 /**
  * Function returns metadata object which needs to be set with the new metadata XML
  * @param BaseObject $object
  * @param MetadataProfile $metadataProfileId
  */
 protected static function createOrFindMetadataObject(BaseObject $object, MetadataProfile $metadataProfile)
 {
     $c = new Criteria();
     $c->addAnd(MetadataPeer::PARTNER_ID, $object->getPartnerId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::OBJECT_ID, $object->getId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::METADATA_PROFILE_ID, $metadataProfile->getId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::METADATA_PROFILE_VERSION, $metadataProfile->getVersion(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::OBJECT_TYPE, kMetadataManager::getTypeNameFromObject($object), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::STATUS, Metadata::STATUS_VALID);
     $dbMetadata = MetadataPeer::doSelectOne($c);
     if (!$dbMetadata) {
         $dbMetadata = new Metadata();
         $dbMetadata->setPartnerId($object->getPartnerId());
         $dbMetadata->setMetadataProfileId($metadataProfile->getId());
         $dbMetadata->setMetadataProfileVersion($metadataProfile->getVersion());
         $dbMetadata->setObjectType(kMetadataManager::getTypeNameFromObject($object));
         $dbMetadata->setObjectId($object->getId());
         $dbMetadata->setStatus(Metadata::STATUS_VALID);
         $dbMetadata->save();
     } else {
         $dbMetadata->incrementVersion();
         $dbMetadata->save();
     }
     return $dbMetadata;
 }