Search in sources :

Example 1 with NamespaceDAO

use of org.alfresco.repo.dictionary.NamespaceDAO in project SearchServices by Alfresco.

the class ModelTrackerTest method setUpTestTrackModels.

@SuppressWarnings("unchecked")
private String setUpTestTrackModels() throws AuthenticationException, IOException, JSONException {
    QName modelName = QName.createQName("qname");
    TYPE type = TYPE.CHANGED;
    Long oldChecksum = new Long(0);
    Long newChecksum = new Long(1);
    AlfrescoModelDiff diff = new AlfrescoModelDiff(modelName, type, oldChecksum, newChecksum);
    List<AlfrescoModelDiff> modelDiffs = new ArrayList<>();
    modelDiffs.add(diff);
    when(this.repositoryClient.getModelsDiff(any(String.class), any(List.class))).thenReturn(modelDiffs);
    final String name = "a model name";
    M2Model model = M2Model.createModel(name);
    M2Model spiedModel = spy(model);
    model.createNamespace("uri", "prefix");
    AlfrescoModel alfrescoModel = new AlfrescoModel(spiedModel, newChecksum);
    when(this.repositoryClient.getModel(any(String.class), eq(modelName))).thenReturn(alfrescoModel);
    NamespaceDAO namespaceDao = mock(NamespaceDAO.class);
    Collection<String> values = new ArrayList<>();
    values.add("prefix");
    when(namespaceDao.getPrefixes(anyString())).thenReturn(values);
    when(this.srv.getNamespaceDAO()).thenReturn(namespaceDao);
    when(this.srv.getM2Model(modelName)).thenReturn(spiedModel);
    when(this.srv.putModel(spiedModel)).thenReturn(true);
    return name;
}
Also used : NamespaceDAO(org.alfresco.repo.dictionary.NamespaceDAO) QName(org.alfresco.service.namespace.QName) M2Model(org.alfresco.repo.dictionary.M2Model) AlfrescoModelDiff(org.alfresco.solr.client.AlfrescoModelDiff) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) AlfrescoModel(org.alfresco.solr.client.AlfrescoModel) TYPE(org.alfresco.solr.client.AlfrescoModelDiff.TYPE)

Example 2 with NamespaceDAO

use of org.alfresco.repo.dictionary.NamespaceDAO in project SearchServices by Alfresco.

the class MetadataTracker method getShardProperty.

public static QName getShardProperty(String field) {
    AlfrescoSolrDataModel dataModel = AlfrescoSolrDataModel.getInstance();
    NamespaceDAO namespaceDAO = dataModel.getNamespaceDAO();
    DictionaryService dictionaryService = dataModel.getDictionaryService(CMISStrictDictionaryService.DEFAULT);
    PropertyDefinition propertyDef = QueryParserUtils.matchPropertyDefinition("http://www.alfresco.org/model/content/1.0", namespaceDAO, dictionaryService, field);
    return propertyDef.getName();
}
Also used : NamespaceDAO(org.alfresco.repo.dictionary.NamespaceDAO) CMISStrictDictionaryService(org.alfresco.opencmis.dictionary.CMISStrictDictionaryService) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) AlfrescoSolrDataModel(org.alfresco.solr.AlfrescoSolrDataModel) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Aggregations

NamespaceDAO (org.alfresco.repo.dictionary.NamespaceDAO)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CMISStrictDictionaryService (org.alfresco.opencmis.dictionary.CMISStrictDictionaryService)1 M2Model (org.alfresco.repo.dictionary.M2Model)1 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)1 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)1 QName (org.alfresco.service.namespace.QName)1 AlfrescoSolrDataModel (org.alfresco.solr.AlfrescoSolrDataModel)1 AlfrescoModel (org.alfresco.solr.client.AlfrescoModel)1 AlfrescoModelDiff (org.alfresco.solr.client.AlfrescoModelDiff)1 TYPE (org.alfresco.solr.client.AlfrescoModelDiff.TYPE)1 Matchers.anyString (org.mockito.Matchers.anyString)1