本文整理汇总了Java中org.alfresco.repo.dictionary.M2Model.createModel方法的典型用法代码示例。如果您正苦于以下问题:Java M2Model.createModel方法的具体用法?Java M2Model.createModel怎么用?Java M2Model.createModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.dictionary.M2Model
的用法示例。
在下文中一共展示了M2Model.createModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
protected void setUp() throws Exception
{
super.setUp();
ctx = ApplicationContextHelper.getApplicationContext();
transactionService = (TransactionService)ctx.getBean("transactionComponent");
contentService = (ContentService)ctx.getBean("contentService");
nodeService = (NodeService)ctx.getBean("nodeService");
scriptService = (ScriptService)ctx.getBean("scriptService");
serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO)ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
BaseNodeServiceTest.loadModel(ctx);
}
示例2: loadModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
/**
* Loads the test model required for building the node graphs
*/
public static DictionaryService loadModel(ApplicationContext applicationContext)
{
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
// done
return dictionary;
}
示例3: onSetUpInTransaction
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
mlAwareNodeService = (NodeService) applicationContext.getBean("mlAwareNodeService");
nodeService = (NodeService) applicationContext.getBean("nodeService");
dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
authenticationComponent.setSystemUserAsCurrentUser();
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/NodeRefTestModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDAO.putModel(model);
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
}
示例4: overrideVersionableAspectProperties
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
protected void overrideVersionableAspectProperties(ApplicationContext ctx)
{
final DictionaryDAO dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
dictionaryDAO.removeModel(QName.createQName("cm:contentmodel"));
M2Model contentModel = M2Model.createModel(getClass().getClassLoader().getResourceAsStream("alfresco/model/contentModel.xml"));
M2Aspect versionableAspect = contentModel.getAspect("cm:versionable");
M2Property prop = versionableAspect.getProperty("cm:initialVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersionOnUpdateProps");
prop.setDefaultValue(Boolean.FALSE.toString());
dictionaryDAO.putModel(contentModel);
}
示例5: loadTestModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
protected void loadTestModel()
{
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/search/impl/MetadataQueryTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDAO.registerListener(this);
dictionaryDAO.reset();
assertNotNull(dictionaryDAO.getClass(TEST_SUPER_CONTENT_TYPE));
}
示例6: createTestCategories
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
/**
* 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();
}
示例7: getModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
public AlfrescoModel getModel(String coreName, QName modelName) throws AuthenticationException, IOException, JSONException
{
// If the model is new to the SOLR side the prefix will be unknown so we can not generate prefixes for the request!
// Always use the full QName with explicit URI
StringBuilder url = new StringBuilder(GET_MODEL);
URLCodec encoder = new URLCodec();
// must send the long name as we may not have the prefix registered
url.append("?modelQName=").append(encoder.encode(modelName.toString(), "UTF-8"));
GetRequest req = new GetRequest(url.toString());
Response response = null;
try
{
response = repositoryHttpClient.sendRequest(req);
if(response.getStatus() != HttpStatus.SC_OK)
{
throw new AlfrescoRuntimeException(coreName + " GetModel return status is " + response.getStatus());
}
return new AlfrescoModel(M2Model.createModel(response.getContentAsStream()),
Long.valueOf(response.getHeader(CHECKSUM_HEADER)));
}
finally
{
if(response != null)
{
response.release();
}
}
}
示例8: setUp
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
protected void setUp() throws Exception
{
ctx = ApplicationContextHelper.getApplicationContext();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/systemModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
nodeService = serviceRegistry.getNodeService();
nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");
transactionService = serviceRegistry.getTransactionService();
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
// create a first store directly
RetryingTransactionCallback<Object> createRootNodeCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_"
+ System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(createRootNodeCallback);
}
示例9: onSetUpInTransaction
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
txnService = (TransactionService) applicationContext.getBean("transactionComponent");
nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO");
dialect = (Dialect) applicationContext.getBean("dialect");
nodeService = (NodeService) applicationContext.getBean("dbNodeService");
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
dictionaryService = loadModel(applicationContext);
txn = restartAuditableTxn(txn);
}
示例10: setUp
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
applicationContext = ApplicationContextHelper.getApplicationContext();
DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = PerformanceNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
dictionaryService = loadModel(applicationContext);
nodeService = (NodeService) applicationContext.getBean("nodeService");
txnService = (TransactionService) applicationContext.getBean("transactionComponent");
contentService = (ContentService) applicationContext.getBean("contentService");
// create a first store directly
RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute()
{
StoreRef storeRef = nodeService.createStore(
StoreRef.PROTOCOL_WORKSPACE,
"Test_" + System.nanoTime());
return nodeService.getRootNode(storeRef);
}
};
rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
}
示例11: createTestModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
private void createTestModel()
{
M2Model model = M2Model.createModel("test:comparepropertyvalueevaluatortest");
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:" + 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());
prop5.setMultiValued(true);
dictionaryDAO.putModel(model);
}
示例12: loadModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
public QName loadModel(InputStream modelStream)
{
try
{
final M2Model model = M2Model.createModel(modelStream);
return loadModel(model);
}
catch(DictionaryException e)
{
throw new DictionaryException("Could not import model", e);
}
}
示例13: getModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
public AlfrescoModel getModel(QName modelName) throws AuthenticationException, IOException, JSONException
{
// If the model is new to the SOLR side the prefix will be unknown so we can not generate prefixes for the request!
// Always use the full QName with explicit URI
StringBuilder url = new StringBuilder(GET_MODEL);
URLCodec encoder = new URLCodec();
// must send the long name as we may not have the prefix registered
url.append("?modelQName=").append(encoder.encode(modelName.toString(), "UTF-8"));
GetRequest req = new GetRequest(url.toString());
Response response = null;
try
{
response = repositoryHttpClient.sendRequest(req);
if(response.getStatus() != HttpStatus.SC_OK)
{
throw new AlfrescoRuntimeException("GetModel return status is " + response.getStatus());
}
return new AlfrescoModel(M2Model.createModel(response.getContentAsStream()),
Long.valueOf(response.getHeader(CHECKSUM_HEADER)));
}
finally
{
if(response != null)
{
response.release();
}
}
}
示例14: testUploadModel_Invalid
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
public void testUploadModel_Invalid() throws Exception
{
long timestamp = System.currentTimeMillis();
final String modelName = getClass().getSimpleName() + timestamp;
final String prefix = "prefix" + timestamp;
final String uri = "uriNamespace" + timestamp;
M2Model model = M2Model.createModel(prefix + QName.NAMESPACE_PREFIX + modelName);
model.setAuthor("Admin");
model.setDescription("Desc");
ByteArrayOutputStream xml = new ByteArrayOutputStream();
model.toXML(xml);
ZipEntryContext context = new ZipEntryContext(modelName + ".xml", xml.toByteArray());
File zipFile = createZip(context);
PostRequest postRequest = buildMultipartPostRequest(zipFile);
sendRequest(postRequest, 409); // no namespace has been defined
// Create two namespaces
model.createNamespace(uri, prefix);
model.createNamespace(uri + "anotherUri", prefix + "anotherPrefix");
xml = new ByteArrayOutputStream();
model.toXML(xml);
context = new ZipEntryContext(modelName + ".xml", xml.toByteArray());
zipFile = createZip(context);
postRequest = buildMultipartPostRequest(zipFile);
sendRequest(postRequest, 409); // custom model can only have one namespace
}
示例15: addTypeTestDataModel
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
private void addTypeTestDataModel()
{
// load in the test model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("org/alfresco/cmis/search/CMIS-query-test-model.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDAO.putModel(model);
((CMISAbstractDictionaryService) cmisDictionaryService).afterDictionaryDestroy();
((CMISAbstractDictionaryService) cmisDictionaryService).afterDictionaryInit();
}