示例#1
0
文件: Add.php 项目: halfer/Meshing
 public function preRunCheck()
 {
     if (!$this->opts->name) {
         throw new Zend_Console_Getopt_Exception('All schemas need an identifying name (use --name)');
     }
     if (!$this->opts->file) {
         throw new Zend_Console_Getopt_Exception('A schema XML file must be specified (use --file)');
     }
     // Let's check that the file exists
     if (!file_exists($this->opts->file)) {
         throw new Zend_Console_Getopt_Exception('The specified XML schema does not exist');
     }
     // @todo Test whether the input XML file already has a schema, unless --force is present
     // ...
     // @todo Do an XML validation check here
     // ...
     // Check that the schema name is not already taken
     Meshing_Utils::initialiseDb();
     $schema = MeshingSchemaQuery::create()->findOneByName($this->opts->name);
     if ($schema) {
         throw new Zend_Console_Getopt_Exception('That schema name is already in use');
     }
     // Try to create the folders required
     $this->schemaDir = $this->projectRoot . Meshing_Utils::getPaths()->getPathSchemasNodes() . '/' . $this->opts->name;
     if (!is_dir($this->schemaDir)) {
         if (!@mkdir($this->schemaDir)) {
             throw new Zend_Console_Getopt_Exception("Error when creating the schema folder '{$this->opts->name}', check permissions?");
         }
     }
 }
示例#2
0
文件: Add.php 项目: halfer/Meshing
 public function preRunCheck()
 {
     if (!$this->opts->name) {
         throw new Zend_Console_Getopt_Exception('The node must have a name (use --name)');
     }
     if (!$this->opts->connection) {
         throw new Zend_Console_Getopt_Exception('The node must have a connection (use --connection)');
     }
     if (!$this->opts->schema) {
         throw new Zend_Console_Getopt_Exception('The node must have a schema (use --schema)');
     }
     // Check that the name supplied is unique
     Meshing_Utils::initialiseDb();
     $node = P2POwnNodeQuery::create()->findOneByName($this->opts->name);
     if ($node) {
         throw new Zend_Console_Getopt_Exception('A node of that name already exists');
     }
     // Check that the connection exists
     $this->connection = P2PConnectionQuery::create()->findOneByName($this->opts->connection);
     if (!$this->connection) {
         throw new Zend_Console_Getopt_Exception('The specified connection is not registered');
     }
     // Check that the schema exists
     $this->schema = MeshingSchemaQuery::create()->findOneByName($this->opts->schema);
     if (!$this->schema) {
         throw new Zend_Console_Getopt_Exception('The specified schema is not registered');
     }
 }
示例#3
0
文件: Delete.php 项目: halfer/Meshing
 public function preRunCheck()
 {
     if (!$this->opts->name) {
         throw new Zend_Console_Getopt_Exception('You need to specify which schema (use --name)');
     }
     // Check that the schema exists
     Meshing_Utils::initialiseDb();
     $this->schema = MeshingSchemaQuery::create()->findOneByName($this->opts->name);
     if (!$this->schema) {
         throw new Zend_Console_Getopt_Exception('That schema is not registered');
     }
     // @todo Check that the schema is not in use on a node
     // ...
 }
示例#4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(MeshingSchemaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             MeshingSchemaQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
示例#5
0
 /**
  * Returns a new MeshingSchemaQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    MeshingSchemaQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof MeshingSchemaQuery) {
         return $criteria;
     }
     $query = new MeshingSchemaQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
示例#6
0
 /**
  * Get the associated MeshingSchema object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     MeshingSchema The associated MeshingSchema object.
  * @throws     PropelException
  */
 public function getMeshingSchema(PropelPDO $con = null)
 {
     if ($this->aMeshingSchema === null && $this->schema_id !== null) {
         $this->aMeshingSchema = MeshingSchemaQuery::create()->findPk($this->schema_id, $con);
         /* The following can be used additionally to
         			guarantee the related object contains a reference
         			to this object.  This level of coupling may, however, be
         			undesirable since it could result in an only partially populated collection
         			in the referenced object.
         			$this->aMeshingSchema->addP2POwnNodes($this);
         		 */
     }
     return $this->aMeshingSchema;
 }
示例#7
0
 /**
  * Creates a new KnownNode for node models
  * 
  * @param PropelPDO $con PDO connection object
  * @return TestModelKnownNode 
  */
 protected function createKnownNode(BaseObject $node, PropelPDO $con = null)
 {
     $this->initConnections();
     // Look up schema, and create an empty one if required
     $schema = MeshingSchemaQuery::create()->findOneByName($this->package, $this->conSystem);
     if (!$schema) {
         $schema = new MeshingSchema();
         $schema->setName($this->package);
         $schema->setInstalledAt(time());
         $schema->save($this->conSystem);
     }
     /* @var $node TestModelKnownNode */
     $node->setName('Us!');
     $node->setFqdn('http://example.com/path');
     $node->setSchemaId($schema->getId());
     $node->save($con);
     return $node;
 }