diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 9f313ec..71fbc53 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1,153 +1,162 @@ 2, 'class' => array( 'SemiStructuredBaseController' => 'controller/SemiStructuredBaseController.php', 'SemiStructuredDAO' => 'storage/SemiStructuredDAO.php', 'SemiStructuredDataApplication' => 'application/SemiStructuredDataApplication.php', 'SemiStructuredInstanceConfiguredCustomField' => 'customfield/SemiStructuredInstanceConfiguredCustomField.php', 'SemiStructuredInstanceConfiguredCustomFieldStorage' => 'storage/SemiStructuredInstanceConfiguredCustomFieldStorage.php', 'SemiStructuredInstanceCustomField' => 'customfield/SemiStructuredInstanceCustomField.php', 'SemiStructuredInstanceCustomFieldNumericIndex' => 'storage/SemiStructuredInstanceCustomFieldNumericIndex.php', 'SemiStructuredInstanceCustomFieldStringIndex' => 'storage/SemiStructuredInstanceCustomFieldStringIndex.php', 'SemiStructuredInstanceEditConduitAPIMethod' => 'conduit/SemiStructuredInstanceEditConduitAPIMethod.php', 'SemiStructuredInstanceSearchConduitAPIMethod' => 'conduit/SemiStructuredInstanceSearchConduitAPIMethod.php', 'SemiStructuredObjectInstance' => 'storage/SemiStructuredObjectInstance.php', 'SemiStructuredObjectInstanceClassTransaction' => 'xaction/instance/SemiStructuredObjectInstanceClassTransaction.php', 'SemiStructuredObjectInstanceController' => 'controller/instance/SemiStructuredObjectInstanceController.php', 'SemiStructuredObjectInstanceDescriptionTransaction' => 'xaction/instance/SemiStructuredObjectInstanceDescriptionTransaction.php', 'SemiStructuredObjectInstanceEditController' => 'controller/instance/SemiStructuredObjectInstanceEditController.php', 'SemiStructuredObjectInstanceEditEngine' => 'editor/SemiStructuredObjectInstanceEditEngine.php', + 'SemiStructuredObjectInstanceFerretEngine' => 'search/SemiStructuredObjectInstanceFerretEngine.php', + 'SemiStructuredObjectInstanceFulltextEngine' => 'search/SemiStructuredObjectInstanceFulltextEngine.php', 'SemiStructuredObjectInstanceListController' => 'controller/instance/SemiStructuredObjectInstanceListController.php', 'SemiStructuredObjectInstanceMailReceiver' => 'mail/SemiStructuredObjectInstanceMailReceiver.php', 'SemiStructuredObjectInstanceNameTransaction' => 'xaction/instance/SemiStructuredObjectInstanceNameTransaction.php', 'SemiStructuredObjectInstancePHIDType' => 'phid/SemiStructuredObjectInstancePHIDType.php', 'SemiStructuredObjectInstanceQuery' => 'query/SemiStructuredObjectInstanceQuery.php', 'SemiStructuredObjectInstanceRawDataTransaction' => 'xaction/instance/SemiStructuredObjectInstanceRawDataTransaction.php', 'SemiStructuredObjectInstanceReplyHandler' => 'mail/SemiStructuredObjectInstanceReplyHandler.php', 'SemiStructuredObjectInstanceSearchEngine' => 'query/SemiStructuredObjectInstanceSearchEngine.php', 'SemiStructuredObjectInstanceTransaction' => 'storage/SemiStructuredObjectInstanceTransaction.php', 'SemiStructuredObjectInstanceTransactionComment' => 'storage/SemiStructuredObjectInstanceTransactionComment.php', 'SemiStructuredObjectInstanceTransactionEditor' => 'editor/SemiStructuredObjectInstanceTransactionEditor.php', 'SemiStructuredObjectInstanceTransactionQuery' => 'query/SemiStructuredObjectInstanceTransactionQuery.php', 'SemiStructuredObjectInstanceTransactionType' => 'xaction/instance/SemiStructuredObjectInstanceTransactionType.php', 'SemiStructuredObjectInstanceViewController' => 'controller/instance/SemiStructuredObjectInstanceViewController.php', 'SemiStructuredObjectNewInstanceController' => 'controller/class/SemiStructuredObjectNewInstanceController.php', 'SemiStructuredObjectType' => 'storage/SemiStructuredObjectType.php', 'SemiStructuredObjectTypeArchiveController' => 'controller/class/SemiStructuredObjectTypeArchiveController.php', 'SemiStructuredObjectTypeController' => 'controller/class/SemiStructuredObjectTypeController.php', 'SemiStructuredObjectTypeCustomFieldsTransaction' => 'xaction/class/SemiStructuredObjectTypeCustomFieldsTransaction.php', 'SemiStructuredObjectTypeDescriptionTransaction' => 'xaction/class/SemiStructuredObjectTypeDescriptionTransaction.php', 'SemiStructuredObjectTypeEditController' => 'controller/class/SemiStructuredObjectTypeEditController.php', 'SemiStructuredObjectTypeEditEngine' => 'editor/SemiStructuredObjectTypeEditEngine.php', - 'SemiStructuredObjectTypeFerretEngine' => 'engine/SemiStructuredObjectTypeFerretEngine.php', + 'SemiStructuredObjectTypeFerretEngine' => 'search/SemiStructuredObjectTypeFerretEngine.php', + 'SemiStructuredObjectTypeFulltextEngine' => 'search/SemiStructuredObjectTypeFulltextEngine.php', 'SemiStructuredObjectTypeListController' => 'controller/class/SemiStructuredObjectTypeListController.php', 'SemiStructuredObjectTypeMailReceiver' => 'mail/SemiStructuredObjectTypeMailReceiver.php', 'SemiStructuredObjectTypeNameTransaction' => 'xaction/class/SemiStructuredObjectTypeNameTransaction.php', 'SemiStructuredObjectTypePHIDType' => 'phid/SemiStructuredObjectTypePHIDType.php', 'SemiStructuredObjectTypeQuery' => 'query/SemiStructuredObjectTypeQuery.php', 'SemiStructuredObjectTypeRemarkupRule' => 'remarkup/SemiStructuredObjectTypeRemarkupRule.php', 'SemiStructuredObjectTypeReplyHandler' => 'mail/SemiStructuredObjectTypeReplyHandler.php', 'SemiStructuredObjectTypeSearchEngine' => 'query/SemiStructuredObjectTypeSearchEngine.php', 'SemiStructuredObjectTypeStatusTransaction' => 'xaction/class/SemiStructuredObjectTypeStatusTransaction.php', 'SemiStructuredObjectTypeTransaction' => 'storage/SemiStructuredObjectTypeTransaction.php', 'SemiStructuredObjectTypeTransactionComment' => 'storage/SemiStructuredObjectTypeTransactionComment.php', 'SemiStructuredObjectTypeTransactionEditor' => 'editor/SemiStructuredObjectTypeTransactionEditor.php', 'SemiStructuredObjectTypeTransactionQuery' => 'query/SemiStructuredObjectTypeTransactionQuery.php', 'SemiStructuredObjectTypeTransactionType' => 'xaction/class/SemiStructuredObjectTypeTransactionType.php', 'SemiStructuredObjectTypeViewController' => 'controller/class/SemiStructuredObjectTypeViewController.php', 'SemiStructuredPatchList' => 'storage/SemiStructuredPatchList.php', 'SemiStructuredSchemaSpec' => 'storage/SemiStructuredSchemaSpec.php', 'SemiStructuredStaticSearchField' => '_to_upstream/SemiStructuredStaticSearchField.php', ), 'function' => array(), 'xmap' => array( 'SemiStructuredBaseController' => 'PhabricatorController', 'SemiStructuredDAO' => 'PhabricatorLiskDAO', 'SemiStructuredDataApplication' => 'PhabricatorApplication', 'SemiStructuredInstanceConfiguredCustomField' => array( 'SemiStructuredInstanceCustomField', 'PhabricatorStandardCustomFieldInterface', ), 'SemiStructuredInstanceConfiguredCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'SemiStructuredInstanceCustomField' => 'PhabricatorCustomField', 'SemiStructuredInstanceCustomFieldNumericIndex' => 'PhabricatorCustomFieldNumericIndexStorage', 'SemiStructuredInstanceCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'SemiStructuredInstanceEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'SemiStructuredInstanceSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'SemiStructuredObjectInstance' => array( 'SemiStructuredDAO', 'PhabricatorPolicyInterface', 'PhabricatorApplicationTransactionInterface', 'PhabricatorSubscribableInterface', 'PhabricatorFlaggableInterface', 'PhabricatorProjectInterface', + 'PhabricatorFerretInterface', + 'PhabricatorFulltextInterface', 'PhabricatorMentionableInterface', + 'PhabricatorConduitResultInterface', 'PhabricatorCustomFieldInterface', 'PhabricatorDestructibleInterface', ), 'SemiStructuredObjectInstanceClassTransaction' => 'SemiStructuredObjectInstanceTransactionType', 'SemiStructuredObjectInstanceController' => 'SemiStructuredBaseController', 'SemiStructuredObjectInstanceDescriptionTransaction' => 'SemiStructuredObjectInstanceTransactionType', 'SemiStructuredObjectInstanceEditController' => 'SemiStructuredBaseController', 'SemiStructuredObjectInstanceEditEngine' => 'PhabricatorEditEngine', + 'SemiStructuredObjectInstanceFerretEngine' => 'PhabricatorFerretEngine', + 'SemiStructuredObjectInstanceFulltextEngine' => 'PhabricatorFulltextEngine', 'SemiStructuredObjectInstanceListController' => 'SemiStructuredObjectTypeController', 'SemiStructuredObjectInstanceMailReceiver' => 'PhabricatorObjectMailReceiver', 'SemiStructuredObjectInstanceNameTransaction' => 'SemiStructuredObjectInstanceTransactionType', 'SemiStructuredObjectInstancePHIDType' => 'PhabricatorPHIDType', 'SemiStructuredObjectInstanceQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'SemiStructuredObjectInstanceRawDataTransaction' => 'SemiStructuredObjectInstanceTransactionType', 'SemiStructuredObjectInstanceReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'SemiStructuredObjectInstanceSearchEngine' => 'PhabricatorApplicationSearchEngine', 'SemiStructuredObjectInstanceTransaction' => 'PhabricatorModularTransaction', 'SemiStructuredObjectInstanceTransactionComment' => 'PhabricatorApplicationTransactionComment', 'SemiStructuredObjectInstanceTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'SemiStructuredObjectInstanceTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'SemiStructuredObjectInstanceTransactionType' => 'PhabricatorModularTransactionType', 'SemiStructuredObjectInstanceViewController' => 'SemiStructuredObjectInstanceController', 'SemiStructuredObjectNewInstanceController' => 'SemiStructuredObjectTypeController', 'SemiStructuredObjectType' => array( 'SemiStructuredDAO', 'PhabricatorPolicyInterface', 'PhabricatorApplicationTransactionInterface', 'PhabricatorMentionableInterface', 'PhabricatorSubscribableInterface', 'PhabricatorProjectInterface', 'PhabricatorFlaggableInterface', 'PhabricatorDestructibleInterface', 'PhabricatorFerretInterface', ), 'SemiStructuredObjectTypeArchiveController' => 'SemiStructuredBaseController', 'SemiStructuredObjectTypeController' => 'SemiStructuredBaseController', 'SemiStructuredObjectTypeCustomFieldsTransaction' => 'SemiStructuredObjectTypeTransactionType', 'SemiStructuredObjectTypeDescriptionTransaction' => 'SemiStructuredObjectTypeTransactionType', 'SemiStructuredObjectTypeEditController' => 'SemiStructuredBaseController', 'SemiStructuredObjectTypeEditEngine' => 'PhabricatorEditEngine', 'SemiStructuredObjectTypeFerretEngine' => 'PhabricatorFerretEngine', + 'SemiStructuredObjectTypeFulltextEngine' => 'PhabricatorFerretEngine', 'SemiStructuredObjectTypeListController' => 'SemiStructuredBaseController', 'SemiStructuredObjectTypeMailReceiver' => 'PhabricatorObjectMailReceiver', 'SemiStructuredObjectTypeNameTransaction' => 'SemiStructuredObjectTypeTransactionType', 'SemiStructuredObjectTypePHIDType' => 'PhabricatorPHIDType', 'SemiStructuredObjectTypeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'SemiStructuredObjectTypeRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'SemiStructuredObjectTypeReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'SemiStructuredObjectTypeSearchEngine' => 'PhabricatorApplicationSearchEngine', 'SemiStructuredObjectTypeStatusTransaction' => 'SemiStructuredObjectTypeTransactionType', 'SemiStructuredObjectTypeTransaction' => 'PhabricatorModularTransaction', 'SemiStructuredObjectTypeTransactionComment' => 'PhabricatorApplicationTransactionComment', 'SemiStructuredObjectTypeTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'SemiStructuredObjectTypeTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'SemiStructuredObjectTypeTransactionType' => 'PhabricatorModularTransactionType', 'SemiStructuredObjectTypeViewController' => 'SemiStructuredObjectTypeController', 'SemiStructuredPatchList' => 'PhabricatorSQLPatchList', 'SemiStructuredSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'SemiStructuredStaticSearchField' => 'PhabricatorSearchField', ), )); diff --git a/src/engine/SemiStructuredObjectTypeFerretEngine.php b/src/search/SemiStructuredObjectInstanceFerretEngine.php similarity index 59% copy from src/engine/SemiStructuredObjectTypeFerretEngine.php copy to src/search/SemiStructuredObjectInstanceFerretEngine.php index 20510df..65333fa 100644 --- a/src/engine/SemiStructuredObjectTypeFerretEngine.php +++ b/src/search/SemiStructuredObjectInstanceFerretEngine.php @@ -1,18 +1,18 @@ setDocumentTitle($instance->getName()); + + $document->addField( + PhabricatorSearchDocumentFieldType::FIELD_BODY, + $instance->getDescription()); + + // TODO raw data? + + + $document->addRelationship( + 'clss', + $instance->getClassPHID(), + SemiStructuredObjectTypePHIDType::TYPECONST, + PhabricatorTime::getNow()); + } +} diff --git a/src/engine/SemiStructuredObjectTypeFerretEngine.php b/src/search/SemiStructuredObjectTypeFerretEngine.php similarity index 100% copy from src/engine/SemiStructuredObjectTypeFerretEngine.php copy to src/search/SemiStructuredObjectTypeFerretEngine.php diff --git a/src/engine/SemiStructuredObjectTypeFerretEngine.php b/src/search/SemiStructuredObjectTypeFulltextEngine.php similarity index 52% rename from src/engine/SemiStructuredObjectTypeFerretEngine.php rename to src/search/SemiStructuredObjectTypeFulltextEngine.php index 20510df..b1a7a17 100644 --- a/src/engine/SemiStructuredObjectTypeFerretEngine.php +++ b/src/search/SemiStructuredObjectTypeFulltextEngine.php @@ -1,18 +1,18 @@ setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) // TODO take policies from class? // ->setEditPolicy($actor->getPHID()) ->setStatus(self::STATUS_ACTIVE); if ($object_class !== null) { $object ->setClassPHID($object_class->getPHID()) ->attachClass($object_class); } return $object; } public function attachClass( SemiStructuredObjectType $object_class = null) { $this->class = $object_class; return $this; } public function getClass() { return $this->assertAttached($this->class); } public function hasAttachedClass() { return $this->class !== self::ATTACHABLE; } public function getURI() { return urisprintf('/semistruct/instance/%d/', $this->getID()); } public function getIcon() { // TODO customize in Type return SemiStructuredDataApplication::ICON_OBJECT_INSTANCE; } public static function getStatusNameMap() { return array( // TODO remove this self::STATUS_ACTIVE => pht('Active'), self::STATUS_ARCHIVED => pht('Archived'), ); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'rawData' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'sort255', 'description' => 'text', 'status' => 'text32', ), self::CONFIG_KEY_SCHEMA => array( 'classPHID' => array( 'columns' => array('classPHID'), ), ), ) + parent::getConfiguration(); } public function getPHIDType() { return SemiStructuredObjectInstancePHIDType::TYPECONST; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new SemiStructuredObjectInstanceTransactionEditor(); } public function getApplicationTransactionTemplate() { return new SemiStructuredObjectInstanceTransaction(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { return ''; // TODO switch ($capability) { // TODO case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return true; } /* -( PhabricatorCustomFieldInterface )------------------------------------ */ public function getCustomFieldSpecificationForRole($role) { return array(); } public function getCustomFieldBaseClass() { return 'SemiStructuredInstanceCustomField'; } public function getCustomFields() { return $this->assertAttached($this->customFields); } public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { $this->customFields = $fields; return $this; } /* -( PhabricatorConduitResultInterface )---------------------------------- */ public function getFieldSpecificationsForConduit() { return array( (new PhabricatorConduitSearchFieldSpecification()) ->setKey('name') ->setType('string') ->setDescription(pht('The name of the instance.')), (new PhabricatorConduitSearchFieldSpecification()) ->setKey('description') ->setType('remarkup') ->setDescription(pht('The description.')), (new PhabricatorConduitSearchFieldSpecification()) ->setKey('classPHID') ->setType('phid') ->setDescription(pht('The Type of this Instance.')), (new PhabricatorConduitSearchFieldSpecification()) ->setKey('rawData') ->setType('map') ->setDescription(pht('The raw structured data')), // TODO custom fields ); } public function getFieldValuesForConduit() { return array( 'name' => $this->getName(), 'description' => array( 'raw' => $this->getDescription(), ), 'classPHID' => $this->getClassPHID(), 'rawData' => json_decode($this->getRawData()), ); } public function getConduitSearchAttachments() { return array(); } +/* -( PhabricatorFerretInterface )----------------------------------------- */ + + + public function newFerretEngine() { + return new SemiStructuredObjectInstanceFerretEngine(); + } + +/* -( PhabricatorFulltextInterface )--------------------------------------- */ + + + public function newFulltextEngine() { + return new SemiStructuredObjectInstanceFulltextEngine(); + } + /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->openTransaction(); $this->delete(); $this->saveTransaction(); } /* -( PhabricatorSubscribableInterface )----------------------------------- */ public function isAutomaticallySubscribed($phid) { return false; } }