public function doTest($path)
 {
     $xsdFiles = array();
     $xsdDir = dir($path);
     while (false !== ($entry = $xsdDir->read())) {
         $matches = null;
         if (!preg_match('/(\\d+)\\.xsd/', $entry, $matches)) {
             continue;
         }
         $version = $matches[1];
         $xsdFiles[$version] = realpath("{$path}/{$entry}");
     }
     $xsdDir->close();
     $this->assertGreaterThan(0, count($xsdFiles), "Folder [{$path}] has no XSD files");
     $versions = array_keys($xsdFiles);
     sort($versions);
     $prevVersion = array_shift($versions);
     foreach ($versions as $currentVersion) {
         $fromXsd = $xsdFiles[$prevVersion];
         $toXsd = $xsdFiles[$currentVersion];
         $xsl = kXsd::compareXsd($fromXsd, $toXsd);
         $this->assertTrue($xsl, "XSD [{$fromXsd} => {$toXsd}] Created XSL");
         $prevVersion = $currentVersion;
     }
 }
Пример #2
0
 /**
  * Check if transforming required and create job if needed
  *
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsd
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevXsd, $newXsd)
 {
     $xsl = true;
     if (!PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_VALIDATION, $metadataProfile->getPartnerId())) {
         $xsl = kXsd::compareXsd($prevXsd, $newXsd);
     }
     if ($xsl === true) {
         return;
     }
     if (PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_TRANSFORMATION, $metadataProfile->getPartnerId())) {
         throw new kXsdException(kXsdException::TRANSFORMATION_REQUIRED);
     }
     $prevVersion = $metadataProfile->getVersion();
     $metadataProfile->incrementVersion();
     $newVersion = $metadataProfile->getVersion();
     $metadataProfile->save();
     //save has to be before we create a batch to make sure there is no race-condition where XSD is not updated before the batch runs.
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }
Пример #3
0
 /**
  * Check if transforming required and create job if needed
  * 
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsdPath
  * 
  * @return BatchJob
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevVersion, $prevXsdPath, $newVersion, $newXsdPath)
 {
     $xsl = kXsd::compareXsd($prevXsdPath, $newXsdPath);
     if (!$xsl) {
         return;
     }
     if (is_bool($xsl)) {
         return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion);
     }
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }
 /**
  * Check if transforming required and create job if needed
  * 
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsdPath
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevVersion, $prevXsdPath, $newVersion, $newXsdPath)
 {
     $xsl = true;
     if (!PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_VALIDATION, $metadataProfile->getPartnerId())) {
         $xsl = kXsd::compareXsd($prevXsdPath, $newXsdPath);
         if (!$xsl) {
             return;
         }
     }
     if (is_bool($xsl)) {
         return self::upgradeMetadataObjects($metadataProfile->getId(), $prevVersion, $newVersion);
     }
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }