customType.setTitle("customSite"); customType.setParentName( SiteModel.SITE_MODEL_PREFIX + ":" + SiteModel.TYPE_SITE.getLocalName() ); M2Property customProp = customType.createProperty("cs:customSiteProp"); customProp.setTitle("customSiteProp"); customProp.setType("d:text");
public Void execute() throws Throwable { type.removeProperty(modelName + ":" + propertyQName.getLocalName()); CompiledModel compiledModel = model.compile(dictionaryDAO, namespaceDAO, true); modelValidator.validateModel(compiledModel); return null; } };
testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName()); M2Property prop1 = testType.createProperty("test:prop1"); prop1.setMandatory(false); prop1.setType("d:" + DataTypeDefinition.TEXT.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);
m2Type.setTitle("Test type title"); m2Type.setParentName("cm:content");
M2Property prop1 = anotherType.createProperty("prop1"); prop1.setType("d:text");
testType.setParentName("cm:" + ContentModel.TYPE_FOLDER.getLocalName()); dictionaryDAO.putModel(testModel); fileFolderService
private QName addModel() { this.testNamespace = "http://www.alfresco.org/test/" + modelName; this.modelQName = QName.createQName(testNamespace, modelName); // Create a model this.model = M2Model.createModel(modelName + ":" + modelName); model.createNamespace(testNamespace, modelName); model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, "d"); model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX); this.typeQName = QName.createQName(testNamespace, "type1"); this.type = model.createType(modelName + ":" + typeQName.getLocalName()); type.setParentName("cm:folder"); this.propertyQName = QName.createQName(testNamespace, "prop1"); this.property = type.createProperty(modelName + ":" + propertyQName.getLocalName()); property.setType("d:text"); dictionaryDAO.putModel(model); return modelQName; }
m2Type.setTitle("Test type title"); m2Type.setParentName("cm:content");
testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName()); M2Property prop1 = testType.createProperty("test:" + PROP_TEXT.getLocalName()); prop1.setMandatory(false); prop1.setType("d:" + DataTypeDefinition.TEXT.getLocalName()); prop1.setMultiValued(false); M2Property prop2 = testType.createProperty("test:" + PROP_INT.getLocalName()); prop2.setMandatory(false); prop2.setType("d:" + DataTypeDefinition.INT.getLocalName()); prop2.setMultiValued(false); M2Property prop3 = testType.createProperty("test:" + PROP_DATETIME.getLocalName()); prop3.setMandatory(false); prop3.setType("d:" + DataTypeDefinition.DATETIME.getLocalName()); prop3.setMultiValued(false); M2Property prop4 = testType.createProperty("test:" + PROP_NODEREF.getLocalName()); prop4.setMandatory(false); prop4.setType("d:" + DataTypeDefinition.NODE_REF.getLocalName()); prop4.setMultiValued(false); M2Property prop5 = testType.createProperty("test:" + PROP_MULTI_VALUE.getLocalName()); prop5.setMandatory(false); prop5.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
m2Type.setTitle("Test type title"); m2Type.setParentName("cm:content");
public Void execute() throws Throwable { type.removeProperty(modelName + ":" + propertyQName.getLocalName()); CompiledModel compiledModel = model.compile(dictionaryDAO, namespaceDAO, true); try { modelValidator.validateModel(compiledModel); fail("Property delete should have failed"); } catch(ModelInUseException e) { System.out.println("help"); // ok } return null; } };
this.type.removeProperty(this.property.getName());