Search in sources :

Example 11 with M2Aspect

use of org.alfresco.repo.dictionary.M2Aspect in project alfresco-repository by Alfresco.

the class CopyServiceImplTest method createTestModel.

/**
 * Creates the test model used by the tests
 */
private void createTestModel() {
    M2Model model = M2Model.createModel("test:nodeoperations");
    model.createNamespace(TEST_TYPE_NAMESPACE, "test");
    model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.DICTIONARY_MODEL_PREFIX);
    model.createImport(NamespaceService.SYSTEM_MODEL_1_0_URI, NamespaceService.SYSTEM_MODEL_PREFIX);
    model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
    M2Type testType = model.createType("test:" + TEST_TYPE_QNAME.getLocalName());
    testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName());
    M2Property prop1 = testType.createProperty("test:" + PROP1_QNAME_MANDATORY.getLocalName());
    prop1.setMandatory(true);
    prop1.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop1.setMultiValued(false);
    M2Property prop2 = testType.createProperty("test:" + PROP2_QNAME_OPTIONAL.getLocalName());
    prop2.setMandatory(false);
    prop2.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop2.setMandatory(false);
    M2Property propNodeRef = testType.createProperty("test:" + PROP_QNAME_MY_NODE_REF.getLocalName());
    propNodeRef.setMandatory(false);
    propNodeRef.setType("d:" + DataTypeDefinition.NODE_REF.getLocalName());
    propNodeRef.setMandatory(false);
    M2Property propAnyNodeRef = testType.createProperty("test:" + PROP_QNAME_MY_ANY.getLocalName());
    propAnyNodeRef.setMandatory(false);
    propAnyNodeRef.setType("d:" + DataTypeDefinition.ANY.getLocalName());
    propAnyNodeRef.setMandatory(false);
    M2ChildAssociation childAssoc = testType.createChildAssociation("test:" + TEST_CHILD_ASSOC_TYPE_QNAME.getLocalName());
    childAssoc.setTargetClassName("sys:base");
    childAssoc.setTargetMandatory(false);
    M2Association assoc = testType.createAssociation("test:" + TEST_ASSOC_TYPE_QNAME.getLocalName());
    assoc.setTargetClassName("sys:base");
    assoc.setTargetMandatory(false);
    M2Aspect testAspect = model.createAspect("test:" + TEST_ASPECT_QNAME.getLocalName());
    M2Property prop3 = testAspect.createProperty("test:" + PROP3_QNAME_MANDATORY.getLocalName());
    prop3.setMandatory(true);
    prop3.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop3.setMultiValued(false);
    M2Property prop4 = testAspect.createProperty("test:" + PROP4_QNAME_OPTIONAL.getLocalName());
    prop4.setMandatory(false);
    prop4.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop4.setMultiValued(false);
    M2Aspect testMandatoryAspect = model.createAspect("test:" + TEST_MANDATORY_ASPECT_QNAME.getLocalName());
    M2Property prop5 = testMandatoryAspect.createProperty("test:" + PROP5_QNAME_MANDATORY.getLocalName());
    prop5.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop5.setMandatory(true);
    testType.addMandatoryAspect("test:" + TEST_MANDATORY_ASPECT_QNAME.getLocalName());
    dictionaryDAO.putModel(model);
}
Also used : M2Association(org.alfresco.repo.dictionary.M2Association) M2Type(org.alfresco.repo.dictionary.M2Type) M2Property(org.alfresco.repo.dictionary.M2Property) M2Model(org.alfresco.repo.dictionary.M2Model) M2Aspect(org.alfresco.repo.dictionary.M2Aspect) M2ChildAssociation(org.alfresco.repo.dictionary.M2ChildAssociation)

Example 12 with M2Aspect

use of org.alfresco.repo.dictionary.M2Aspect in project alfresco-repository by Alfresco.

the class RuleServiceCoverageTest method createTestCategories.

/**
 * Create the categories used in the tests
 */
private void createTestCategories() {
    // Create the test model
    M2Model model = M2Model.createModel("test:rulecategory");
    model.createNamespace(TEST_NAMESPACE, "test");
    model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, "d");
    model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
    // Create the region category
    regionCategorisationQName = QName.createQName(TEST_NAMESPACE, "region");
    M2Aspect generalCategorisation = model.createAspect("test:" + regionCategorisationQName.getLocalName());
    generalCategorisation.setParentName("cm:" + ContentModel.ASPECT_CLASSIFIABLE.getLocalName());
    M2Property genCatProp = generalCategorisation.createProperty("test:region");
    genCatProp.setIndexed(true);
    genCatProp.setIndexedAtomically(true);
    genCatProp.setMandatory(true);
    genCatProp.setMultiValued(true);
    genCatProp.setStoredInIndex(true);
    genCatProp.setIndexTokenisationMode(IndexTokenisationMode.TRUE);
    genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName());
    // Save the mode
    dictionaryDAO.putModel(model);
    // Create the category value container and root
    catContainer = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, "categoryContainer"), ContentModel.TYPE_CONTAINER).getChildRef();
    catRoot = nodeService.createNode(catContainer, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, "categoryRoot"), ContentModel.TYPE_CATEGORYROOT).getChildRef();
    // Create the category values
    catRBase = nodeService.createNode(catRoot, ContentModel.ASSOC_CATEGORIES, QName.createQName(TEST_NAMESPACE, "region"), ContentModel.TYPE_CATEGORY).getChildRef();
    catROne = nodeService.createNode(catRBase, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "Europe"), ContentModel.TYPE_CATEGORY).getChildRef();
    catRTwo = nodeService.createNode(catRBase, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "RestOfWorld"), ContentModel.TYPE_CATEGORY).getChildRef();
    catRThree = nodeService.createNode(catRTwo, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "US"), ContentModel.TYPE_CATEGORY).getChildRef();
}
Also used : M2Property(org.alfresco.repo.dictionary.M2Property) M2Model(org.alfresco.repo.dictionary.M2Model) M2Aspect(org.alfresco.repo.dictionary.M2Aspect)

Aggregations

M2Aspect (org.alfresco.repo.dictionary.M2Aspect)12 M2Model (org.alfresco.repo.dictionary.M2Model)12 M2Property (org.alfresco.repo.dictionary.M2Property)6 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)5 QName (org.alfresco.service.namespace.QName)5 M2ClassAssociation (org.alfresco.repo.dictionary.M2ClassAssociation)4 ParameterCheck.mandatoryString (org.springframework.extensions.surf.util.ParameterCheck.mandatoryString)3 HashMap (java.util.HashMap)2 M2Type (org.alfresco.repo.dictionary.M2Type)2 ParameterCheck.mandatoryString (org.alfresco.util.ParameterCheck.mandatoryString)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 DictionaryDAO (org.alfresco.repo.dictionary.DictionaryDAO)1 M2Association (org.alfresco.repo.dictionary.M2Association)1 M2ChildAssociation (org.alfresco.repo.dictionary.M2ChildAssociation)1 M2Constraint (org.alfresco.repo.dictionary.M2Constraint)1 CustomAspect (org.alfresco.rest.api.model.CustomAspect)1 CustomModelConstraint (org.alfresco.rest.api.model.CustomModelConstraint)1 CustomType (org.alfresco.rest.api.model.CustomType)1