Search in sources :

Example 1 with PropertyValue

use of org.alfresco.solr.client.PropertyValue in project SearchServices by Alfresco.

the class SolrInformationServer method addToNewDocAndCache.

private void addToNewDocAndCache(NodeMetaData nodeMetaData, SolrInputDocument newDoc) throws IOException, AuthenticationException {
    addFieldsToDoc(nodeMetaData, newDoc);
    SolrInputDocument cachedDoc = null;
    boolean isContentIndexedForNode = isContentIndexedForNode(nodeMetaData.getProperties());
    String fixedTenantDomain = AlfrescoSolrDataModel.getTenantId(nodeMetaData.getTenantDomain());
    if (isContentIndexedForNode) {
        cachedDoc = solrContentStore.retrieveDocFromSolrContentStore(fixedTenantDomain, nodeMetaData.getId());
    }
    Map<QName, PropertyValue> properties = nodeMetaData.getProperties();
    addPropertiesToDoc(properties, isContentIndexedForNode, newDoc, cachedDoc, transformContent);
    // System.out.println("##### Doc Following Properties:"+newDoc.toString());
    // Now that the new doc is fully updated and ready to go to the Solr index, cache it.
    solrContentStore.storeDocOnSolrContentStore(fixedTenantDomain, nodeMetaData.getId(), newDoc);
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) QName(org.alfresco.service.namespace.QName) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue)

Example 2 with PropertyValue

use of org.alfresco.solr.client.PropertyValue in project SearchServices by Alfresco.

the class SolrInformationServer method addStringPropertyToDoc.

private static void addStringPropertyToDoc(SolrInputDocument doc, FieldInstance field, StringPropertyValue stringPropertyValue, Map<QName, PropertyValue> properties) throws IOException {
    if (field.isLocalised()) {
        Locale locale = null;
        PropertyValue localePropertyValue = properties.get(ContentModel.PROP_LOCALE);
        if (localePropertyValue != null) {
            locale = DefaultTypeConverter.INSTANCE.convert(Locale.class, ((StringPropertyValue) localePropertyValue).getValue());
        }
        if (locale == null) {
            locale = I18NUtil.getLocale();
        }
        StringBuilder builder;
        builder = new StringBuilder();
        builder.append("\u0000").append(locale.toString()).append("\u0000").append(stringPropertyValue.getValue());
        doc.addField(field.getField(), builder.toString());
    } else {
        doc.addField(field.getField(), stringPropertyValue.getValue());
    }
    addFieldIfNotSet(doc, field);
}
Also used : Locale(java.util.Locale) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue)

Example 3 with PropertyValue

use of org.alfresco.solr.client.PropertyValue in project SearchServices by Alfresco.

the class LoadAFTSTestData method loadMntTestData.

public static void loadMntTestData() throws Exception {
    SolrCore core = h.getCore();
    properties19 = new HashMap<QName, PropertyValue>();
    properties19.put(ContentModel.PROP_NAME, new StringPropertyValue("Test.hello.txt"));
    n19NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n19QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "nineteen");
    n19CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n19QName, n19NodeRef, true, 0);
    addNode(core, dataModel, 1, 19, 1, ContentModel.TYPE_CONTENT, null, properties19, null, "system", new ChildAssociationRef[] { n19CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n19QName.toString() }, n19NodeRef, true);
    properties20 = new HashMap<QName, PropertyValue>();
    properties20.put(ContentModel.PROP_NAME, new StringPropertyValue("Test1.hello.txt"));
    n20NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n20QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twenty");
    n20CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n20QName, n20NodeRef, true, 0);
    addNode(core, dataModel, 1, 20, 1, ContentModel.TYPE_CONTENT, null, properties20, null, "system", new ChildAssociationRef[] { n20CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n20QName.toString() }, n20NodeRef, true);
    properties21 = new HashMap<QName, PropertyValue>();
    properties21.put(ContentModel.PROP_NAME, new StringPropertyValue("one_two_three.txt"));
    n21NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n21QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentyone");
    n21CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n21QName, n21NodeRef, true, 0);
    addNode(core, dataModel, 1, 21, 1, ContentModel.TYPE_CONTENT, null, properties21, null, "system", new ChildAssociationRef[] { n21CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n21QName.toString() }, n21NodeRef, true);
    properties22 = new HashMap<QName, PropertyValue>();
    properties22.put(ContentModel.PROP_NAME, new StringPropertyValue("one_two_four.txt"));
    n22NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n22QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twnetytwo");
    n22CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n22QName, n22NodeRef, true, 0);
    addNode(core, dataModel, 1, 22, 1, ContentModel.TYPE_CONTENT, null, properties22, null, "system", new ChildAssociationRef[] { n22CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n22QName.toString() }, n22NodeRef, true);
    properties23 = new HashMap<QName, PropertyValue>();
    properties23.put(ContentModel.PROP_NAME, new StringPropertyValue("one_two.txt"));
    n23NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n23QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentythree");
    n23CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n23QName, n23NodeRef, true, 0);
    addNode(core, dataModel, 1, 23, 1, ContentModel.TYPE_CONTENT, null, properties23, null, "system", new ChildAssociationRef[] { n23CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n23QName.toString() }, n23NodeRef, true);
    properties24 = new HashMap<QName, PropertyValue>();
    properties24.put(ContentModel.PROP_NAME, new StringPropertyValue("Print-Toolkit-3204-The-Print-Toolkit-has-a-new-look-565022.html"));
    n24NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n24QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentyfour");
    n24CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n24QName, n24NodeRef, true, 0);
    addNode(core, dataModel, 1, 24, 1, ContentModel.TYPE_CONTENT, null, properties24, null, "system", new ChildAssociationRef[] { n24CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n24QName.toString() }, n24NodeRef, true);
    properties25 = new HashMap<QName, PropertyValue>();
    properties25.put(ContentModel.PROP_NAME, new StringPropertyValue("Print-Toolkitf-3204-The-Print-Toolkit-has-a-new-look-565022.html"));
    n25NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n25QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentyfive");
    n25CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n25QName, n25NodeRef, true, 0);
    addNode(core, dataModel, 1, 25, 1, ContentModel.TYPE_CONTENT, null, properties25, null, "system", new ChildAssociationRef[] { n25CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n25QName.toString() }, n25NodeRef, true);
    properties26 = new HashMap<QName, PropertyValue>();
    properties26.put(ContentModel.PROP_NAME, new StringPropertyValue("apple pear peach 20150911100000.txt"));
    n26NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n26QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentysix");
    n26CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n26QName, n26NodeRef, true, 0);
    addNode(core, dataModel, 1, 26, 1, ContentModel.TYPE_CONTENT, null, properties26, null, "system", new ChildAssociationRef[] { n26CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n26QName.toString() }, n26NodeRef, true);
    properties27 = new HashMap<QName, PropertyValue>();
    properties27.put(ContentModel.PROP_NAME, new StringPropertyValue("Craig.txt"));
    properties27.put(ContentModel.PROP_CONTENT, new ContentPropertyValue(Locale.UK, 0l, "UTF-8", "text/plain", null));
    content27 = new HashMap<QName, String>();
    content27.put(ContentModel.PROP_CONTENT, "AnalystName Craig");
    n27NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n27QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentyseven");
    n27CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n27QName, n27NodeRef, true, 0);
    addNode(core, dataModel, 1, 27, 1, ContentModel.TYPE_CONTENT, null, properties27, content27, "system", new ChildAssociationRef[] { n27CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n27QName.toString() }, n27NodeRef, true);
    properties28 = new HashMap<QName, PropertyValue>();
    properties28.put(ContentModel.PROP_NAME, new StringPropertyValue("Scott.txt"));
    properties28.put(ContentModel.PROP_CONTENT, new ContentPropertyValue(Locale.UK, 0l, "UTF-8", "text/plain", null));
    content28 = new HashMap<QName, String>();
    content28.put(ContentModel.PROP_CONTENT, "AnalystName Scott \n Craig");
    n28NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n28QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentyeight");
    n28CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n28QName, n28NodeRef, true, 0);
    addNode(core, dataModel, 1, 28, 1, ContentModel.TYPE_CONTENT, null, properties28, content28, "system", new ChildAssociationRef[] { n28CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n28QName.toString() }, n28NodeRef, true);
    properties29 = new HashMap<QName, PropertyValue>();
    properties29.put(ContentModel.PROP_NAME, new StringPropertyValue("BASF_2016.txt"));
    n29NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n29QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twentynine");
    n29CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n29QName, n29NodeRef, true, 0);
    addNode(core, dataModel, 1, 29, 1, ContentModel.TYPE_CONTENT, null, properties29, null, "system", new ChildAssociationRef[] { n29CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n29QName.toString() }, n29NodeRef, true);
    properties30 = new HashMap<QName, PropertyValue>();
    properties30.put(ContentModel.PROP_NAME, new StringPropertyValue("BASF_2016(GMT0800).txt"));
    n30NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n30QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thirty");
    n30CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n30QName, n30NodeRef, true, 0);
    addNode(core, dataModel, 1, 30, 1, ContentModel.TYPE_CONTENT, null, properties30, null, "system", new ChildAssociationRef[] { n30CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n30QName.toString() }, n30NodeRef, true);
    properties31 = new HashMap<QName, PropertyValue>();
    properties31.put(ContentModel.PROP_NAME, new StringPropertyValue("BASF_2016-03-08-10-42-19.txt"));
    n31NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n31QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thirtyone");
    n31CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n31QName, n31NodeRef, true, 0);
    addNode(core, dataModel, 1, 31, 1, ContentModel.TYPE_CONTENT, null, properties31, null, "system", new ChildAssociationRef[] { n31CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n31QName.toString() }, n31NodeRef, true);
    properties32 = new HashMap<QName, PropertyValue>();
    properties32.put(ContentModel.PROP_NAME, new StringPropertyValue("BASF_2016 GMT 0800.txt"));
    n32NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n32QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thirtytwo");
    n32CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rootNodeRef, n32QName, n32NodeRef, true, 0);
    addNode(core, dataModel, 1, 32, 1, ContentModel.TYPE_CONTENT, null, properties32, null, "system", new ChildAssociationRef[] { n32CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n32QName.toString() }, n32NodeRef, true);
}
Also used : StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) SolrCore(org.apache.solr.core.SolrCore) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue)

Example 4 with PropertyValue

use of org.alfresco.solr.client.PropertyValue in project SearchServices by Alfresco.

the class LoadAFTSTestData method loadTestSet.

@BeforeClass
public static void loadTestSet() throws Exception {
    initAlfrescoCore("schema.xml");
    Thread.sleep(1000);
    // Root
    SolrCore core = h.getCore();
    AlfrescoSolrDataModel dataModel = AlfrescoSolrDataModel.getInstance();
    dataModel.getNamespaceDAO().removePrefix("");
    dataModel.setCMDefaultUri();
    rootNodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    addStoreRoot(core, dataModel, rootNodeRef, 1, 1, 1, 1);
    // 1
    n01NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n01QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "one");
    n01CAR = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, n01QName, n01NodeRef, true, 0);
    addNode(core, dataModel, 1, 2, 1, testSuperType, null, getOrderProperties(), null, "andy", new ChildAssociationRef[] { n01CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n01QName.toString() }, n01NodeRef, true);
    testNodeRef = n01NodeRef;
    // 2
    n02NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n02QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "two");
    n02CAR = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, n02QName, n02NodeRef, true, 0);
    addNode(core, dataModel, 1, 3, 1, testSuperType, null, getOrderProperties(), null, "bob", new ChildAssociationRef[] { n02CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n02QName.toString() }, n02NodeRef, true);
    // 3
    n03NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n03QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "three");
    n03CAR = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, n03QName, n03NodeRef, true, 0);
    addNode(core, dataModel, 1, 4, 1, testSuperType, null, getOrderProperties(), null, "cid", new ChildAssociationRef[] { n03CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n03QName.toString() }, n03NodeRef, true);
    // 4
    properties04 = new HashMap<QName, PropertyValue>();
    content04 = new HashMap<QName, String>();
    properties04.putAll(getOrderProperties());
    properties04.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"), new StringPropertyValue("TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYONE"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "text-indexed-unstored-tokenised-atomic"), new StringPropertyValue("TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYUNSTORED"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-nonatomic"), new StringPropertyValue("TEXT THAT IS INDEXED STORED AND TOKENISED BUT NOT ATOMICALLY KEYTWO"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "int-ista"), new StringPropertyValue("1"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "long-ista"), new StringPropertyValue("2"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "float-ista"), new StringPropertyValue("3.4"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "double-ista"), new StringPropertyValue("5.6"));
    Calendar c = new GregorianCalendar();
    c.setTime(new Date(((new Date().getTime() - 10000))));
    Date testDate = c.getTime();
    ftsTestDate = testDate;
    properties04.put(QName.createQName(TEST_NAMESPACE, "date-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, testDate)));
    properties04.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, testDate)));
    properties04.put(QName.createQName(TEST_NAMESPACE, "boolean-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, Boolean.valueOf(true))));
    properties04.put(QName.createQName(TEST_NAMESPACE, "qname-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, QName.createQName("{wibble}wobble"))));
    properties04.put(QName.createQName(TEST_NAMESPACE, "category-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new NodeRef(new StoreRef("proto", "id"), "CategoryId"))));
    properties04.put(QName.createQName(TEST_NAMESPACE, "noderef-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, n01NodeRef)));
    properties04.put(QName.createQName(TEST_NAMESPACE, "path-ista"), new StringPropertyValue("/" + n03QName.toString()));
    properties04.put(QName.createQName(TEST_NAMESPACE, "locale-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, Locale.UK)));
    properties04.put(QName.createQName(TEST_NAMESPACE, "period-ista"), new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period|12"))));
    properties04.put(QName.createQName(TEST_NAMESPACE, "null"), null);
    MultiPropertyValue list_0 = new MultiPropertyValue();
    list_0.addValue(new StringPropertyValue("one"));
    list_0.addValue(new StringPropertyValue("two"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "list"), list_0);
    MLTextPropertyValue mlText = new MLTextPropertyValue();
    mlText.addValue(Locale.ENGLISH, "banana");
    mlText.addValue(Locale.FRENCH, "banane");
    mlText.addValue(Locale.CHINESE, "香蕉");
    mlText.addValue(new Locale("nl"), "banaan");
    mlText.addValue(Locale.GERMAN, "banane");
    mlText.addValue(new Locale("el"), "μπανάνα");
    mlText.addValue(Locale.ITALIAN, "banana");
    mlText.addValue(new Locale("ja"), "バナナ");
    mlText.addValue(new Locale("ko"), "바나나");
    mlText.addValue(new Locale("pt"), "banana");
    mlText.addValue(new Locale("ru"), "банан");
    mlText.addValue(new Locale("es"), "plátano");
    properties04.put(QName.createQName(TEST_NAMESPACE, "ml"), mlText);
    MultiPropertyValue list_1 = new MultiPropertyValue();
    list_1.addValue(new StringPropertyValue("100"));
    list_1.addValue(new StringPropertyValue("anyValueAsString"));
    properties04.put(QName.createQName(TEST_NAMESPACE, "any-many-ista"), list_1);
    MultiPropertyValue list_2 = new MultiPropertyValue();
    list_2.addValue(new ContentPropertyValue(Locale.ENGLISH, 12L, "UTF-16", "text/plain", null));
    properties04.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), list_2);
    content04.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), "multicontent");
    MLTextPropertyValue mlText1 = new MLTextPropertyValue();
    mlText1.addValue(Locale.ENGLISH, "cabbage");
    mlText1.addValue(Locale.FRENCH, "chou");
    MLTextPropertyValue mlText2 = new MLTextPropertyValue();
    mlText2.addValue(Locale.ENGLISH, "lemur");
    mlText2.addValue(new Locale("ru"), "лемур");
    MultiPropertyValue list_3 = new MultiPropertyValue();
    list_3.addValue(mlText1);
    list_3.addValue(mlText2);
    properties04.put(QName.createQName(TEST_NAMESPACE, "mltext-many-ista"), list_3);
    MultiPropertyValue list_4 = new MultiPropertyValue();
    list_4.addValue(null);
    properties04.put(QName.createQName(TEST_NAMESPACE, "nullist"), list_4);
    n04NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n04QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "four");
    n04CAR = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, n04QName, n04NodeRef, true, 0);
    properties04.put(QName.createQName(TEST_NAMESPACE, "aspectProperty"), new StringPropertyValue(""));
    addNode(core, dataModel, 1, 5, 1, testType, new QName[] { testAspect }, properties04, content04, "dave", new ChildAssociationRef[] { n04CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + n04QName.toString() }, n04NodeRef, true);
    // 5
    n05NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n05QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "five");
    n05CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n01NodeRef, n05QName, n05NodeRef, true, 0);
    addNode(core, dataModel, 1, 6, 1, testSuperType, null, getOrderProperties(), null, "eoin", new ChildAssociationRef[] { n05CAR }, new NodeRef[] { rootNodeRef, n01NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() }, n05NodeRef, true);
    // 6
    n06NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n06QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "six");
    n06CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n01NodeRef, n06QName, n06NodeRef, true, 0);
    addNode(core, dataModel, 1, 7, 1, testSuperType, null, getOrderProperties(), null, "fred", new ChildAssociationRef[] { n06CAR }, new NodeRef[] { rootNodeRef, n01NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n06QName.toString() }, n06NodeRef, true);
    // 7
    n07NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n07QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "seven");
    n07CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n02NodeRef, n07QName, n07NodeRef, true, 0);
    addNode(core, dataModel, 1, 8, 1, testSuperType, null, getOrderProperties(), null, "gail", new ChildAssociationRef[] { n07CAR }, new NodeRef[] { rootNodeRef, n02NodeRef }, new String[] { "/" + n02QName.toString() + "/" + n07QName.toString() }, n07NodeRef, true);
    // 8
    n08NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n08QName_0 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "eight-0");
    n08QName_1 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "eight-1");
    n08QName_2 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "eight-2");
    n08CAR_0 = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, n08QName_0, n08NodeRef, false, 2);
    n08CAR_1 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n01NodeRef, n08QName_1, n08NodeRef, false, 1);
    n08CAR_2 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n02NodeRef, n08QName_2, n08NodeRef, true, 0);
    addNode(core, dataModel, 1, 9, 1, testSuperType, null, getOrderProperties(), null, "hal", new ChildAssociationRef[] { n08CAR_0, n08CAR_1, n08CAR_2 }, new NodeRef[] { rootNodeRef, rootNodeRef, n01NodeRef, rootNodeRef, n02NodeRef }, new String[] { "/" + n08QName_0, "/" + n01QName.toString() + "/" + n08QName_1.toString(), "/" + n02QName.toString() + "/" + n08QName_2.toString() }, n08NodeRef, true);
    // 9
    n09NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n09QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "nine");
    n09CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n05NodeRef, n09QName, n09NodeRef, true, 0);
    addNode(core, dataModel, 1, 10, 1, testSuperType, null, getOrderProperties(), null, "ian", new ChildAssociationRef[] { n09CAR }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n09QName }, n09NodeRef, true);
    // 10
    n10NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n10QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "ten");
    n10CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n05NodeRef, n10QName, n10NodeRef, true, 0);
    addNode(core, dataModel, 1, 11, 1, testSuperType, null, getOrderProperties(), null, "jake", new ChildAssociationRef[] { n10CAR }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n10QName }, n10NodeRef, true);
    // 11
    n11NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n11QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "eleven");
    n11CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n05NodeRef, n11QName, n11NodeRef, true, 0);
    addNode(core, dataModel, 1, 12, 1, testSuperType, null, getOrderProperties(), null, "kara", new ChildAssociationRef[] { n11CAR }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n11QName }, n11NodeRef, true);
    // 12
    n12NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n12QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "twelve");
    n12CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n05NodeRef, n12QName, n12NodeRef, true, 0);
    addNode(core, dataModel, 1, 13, 1, testSuperType, null, getOrderProperties(), null, "loon", new ChildAssociationRef[] { n12CAR }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n12QName }, n12NodeRef, true);
    // 13
    n13NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n13QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thirteen");
    n13QNameLink = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "link");
    n13CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n12NodeRef, n13QName, n13NodeRef, true, 0);
    n13CARLink = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n02NodeRef, n13QName, n13NodeRef, false, 0);
    addNode(core, dataModel, 1, 14, 1, testSuperType, null, getOrderProperties(), null, "mike", new ChildAssociationRef[] { n13CAR, n13CARLink }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef, n12NodeRef, rootNodeRef, n02NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n12QName + "/" + n13QName, "/" + n02QName.toString() + "/" + n13QNameLink }, n13NodeRef, true);
    // 14
    properties14 = new HashMap<QName, PropertyValue>();
    properties14.putAll(getOrderProperties());
    content14 = new HashMap<QName, String>();
    MLTextPropertyValue desc1 = new MLTextPropertyValue();
    desc1.addValue(Locale.ENGLISH, "Alfresco tutorial");
    desc1.addValue(Locale.US, "Alfresco tutorial");
    Date explicitCreatedDate = new Date();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    properties14.put(ContentModel.PROP_CONTENT, new ContentPropertyValue(Locale.UK, 298L, "UTF-8", "text/plain", null));
    content14.put(ContentModel.PROP_CONTENT, "The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words;  a an and are" + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: " + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF");
    properties14.put(ContentModel.PROP_DESCRIPTION, desc1);
    properties14.put(ContentModel.PROP_CREATED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, explicitCreatedDate)));
    properties14.put(ContentModel.PROP_MODIFIED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, explicitCreatedDate)));
    MLTextPropertyValue title = new MLTextPropertyValue();
    title.addValue(Locale.ENGLISH, "English123");
    title.addValue(Locale.FRENCH, "French123");
    properties14.put(ContentModel.PROP_TITLE, title);
    n14NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n14QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "fourteen");
    n14QNameCommon = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "common");
    n14CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n13NodeRef, n14QName, n14NodeRef, true, 0);
    n14CAR_1 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n01NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    n14CAR_2 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n02NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    n14CAR_5 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n05NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    n14CAR_6 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n06NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    n14CAR_12 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n12NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    n14CAR_13 = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n13NodeRef, n14QNameCommon, n14NodeRef, false, 0);
    addNode(core, dataModel, 1, 15, 1, ContentModel.TYPE_CONTENT, new QName[] { ContentModel.ASPECT_TITLED }, properties14, content14, "noodle", new ChildAssociationRef[] { n14CAR, n14CAR_1, n14CAR_2, n14CAR_5, n14CAR_6, n14CAR_12, n14CAR_13 }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef, n12NodeRef, n13NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n12QName + "/" + n13QName + "/" + n14QName, "/" + n02QName.toString() + "/" + n13QNameLink + "/" + n14QName, "/" + n01QName + "/" + n14QNameCommon, "/" + n02QName + "/" + n14QNameCommon, "/" + n01QName + "/" + n05QName + "/" + n14QNameCommon, "/" + n01QName + "/" + n06QName + "/" + n14QNameCommon, "/" + n01QName + "/" + n05QName + "/" + n12QName + "/" + n14QNameCommon, "/" + n01QName + "/" + n05QName + "/" + n12QName + "/" + n13QName + "/" + n14QNameCommon }, n14NodeRef, true);
    // 15
    properties15 = new HashMap<QName, PropertyValue>();
    properties15.putAll(getOrderProperties());
    properties15.put(ContentModel.PROP_MODIFIED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, explicitCreatedDate)));
    content15 = new HashMap<QName, String>();
    content15.put(ContentModel.PROP_CONTENT, "          ");
    n15NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    n15QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "fifteen");
    n15CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, n13NodeRef, n15QName, n15NodeRef, true, 0);
    addNode(core, dataModel, 1, 16, 1, ContentModel.TYPE_THUMBNAIL, null, properties15, content15, "ood", new ChildAssociationRef[] { n15CAR }, new NodeRef[] { rootNodeRef, n01NodeRef, n05NodeRef, n12NodeRef, n13NodeRef }, new String[] { "/" + n01QName.toString() + "/" + n05QName.toString() + "/" + n12QName + "/" + n13QName + "/" + n15QName, "/" + n02QName.toString() + "/" + n13QNameLink + "/" + n14QName }, n15NodeRef, true);
}
Also used : Locale(java.util.Locale) StoreRef(org.alfresco.service.cmr.repository.StoreRef) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) SolrCore(org.apache.solr.core.SolrCore) QName(org.alfresco.service.namespace.QName) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) Period(org.alfresco.service.cmr.repository.Period) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) AlfrescoSolrDataModel(org.alfresco.solr.AlfrescoSolrDataModel) Date(java.util.Date) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) NodeRef(org.alfresco.service.cmr.repository.NodeRef) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) BeforeClass(org.junit.BeforeClass)

Example 5 with PropertyValue

use of org.alfresco.solr.client.PropertyValue in project SearchServices by Alfresco.

the class LoadAFTSTestData method getOrderProperties.

private static Map<QName, PropertyValue> getOrderProperties() {
    double orderDoubleCount = -0.11d + orderTextCount * ((orderTextCount % 2 == 0) ? 0.1d : -0.1d);
    float orderFloatCount = -3.5556f + orderTextCount * ((orderTextCount % 2 == 0) ? 0.82f : -0.82f);
    long orderLongCount = -1999999999999999l + orderTextCount * ((orderTextCount % 2 == 0) ? 299999999999999l : -299999999999999l);
    int orderIntCount = -45764576 + orderTextCount * ((orderTextCount % 2 == 0) ? 8576457 : -8576457);
    Map<QName, PropertyValue> testProperties = new HashMap<QName, PropertyValue>();
    testProperties.put(createdDate, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
    testProperties.put(createdTime, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
    testProperties.put(orderDouble, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDoubleCount)));
    testProperties.put(orderFloat, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderFloatCount)));
    testProperties.put(orderLong, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderLongCount)));
    testProperties.put(orderInt, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderIntCount)));
    testProperties.put(orderText, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " cabbage")));
    testProperties.put(ContentModel.PROP_NAME, new StringPropertyValue(orderNames[orderTextCount]));
    testProperties.put(orderLocalisedText, new StringPropertyValue(orderLocalisedNames[orderTextCount]));
    MLTextPropertyValue mlTextPropLocalisedOrder = new MLTextPropertyValue();
    if (orderLocaliseMLText_en[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.ENGLISH, orderLocaliseMLText_en[orderTextCount]);
    }
    if (orderLocaliseMLText_fr[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.FRENCH, orderLocaliseMLText_fr[orderTextCount]);
    }
    if (orderLocaliseMLText_es[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(new Locale("es"), orderLocaliseMLText_es[orderTextCount]);
    }
    if (orderLocaliseMLText_de[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.GERMAN, orderLocaliseMLText_de[orderTextCount]);
    }
    testProperties.put(orderLocalisedMLText, mlTextPropLocalisedOrder);
    MLTextPropertyValue mlTextPropVal = new MLTextPropertyValue();
    mlTextPropVal.addValue(Locale.ENGLISH, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " banana");
    mlTextPropVal.addValue(Locale.FRENCH, new String(new char[] { (char) ('L' + ((orderTextCount % 2 == 0) ? -orderTextCount : orderTextCount)) }) + " banane");
    mlTextPropVal.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " 香蕉");
    testProperties.put(orderMLText, mlTextPropVal);
    orderDate = Duration.subtract(orderDate, new Duration("P1D"));
    orderTextCount++;
    return testProperties;
}
Also used : Locale(java.util.Locale) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) Duration(org.alfresco.service.cmr.repository.datatype.Duration) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue)

Aggregations

PropertyValue (org.alfresco.solr.client.PropertyValue)17 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)17 QName (org.alfresco.service.namespace.QName)16 MLTextPropertyValue (org.alfresco.solr.client.MLTextPropertyValue)15 ContentPropertyValue (org.alfresco.solr.client.ContentPropertyValue)14 MultiPropertyValue (org.alfresco.solr.client.MultiPropertyValue)12 NodeRef (org.alfresco.service.cmr.repository.NodeRef)11 StoreRef (org.alfresco.service.cmr.repository.StoreRef)11 HashMap (java.util.HashMap)10 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)10 Date (java.util.Date)5 SolrCore (org.apache.solr.core.SolrCore)4 BeforeClass (org.junit.BeforeClass)4 GregorianCalendar (java.util.GregorianCalendar)3 Locale (java.util.Locale)3 AlfrescoSolrDataModel (org.alfresco.solr.AlfrescoSolrDataModel)3 NodeMetaData (org.alfresco.solr.client.NodeMetaData)3 SolrInputDocument (org.apache.solr.common.SolrInputDocument)3 NodeMetaDataParameters (org.alfresco.solr.client.NodeMetaDataParameters)2 IOException (java.io.IOException)1