Search in sources :

Example 11 with PropertyValue

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

the class SortCMISTest method addSortableNull.

private void addSortableNull(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName, Date date1, String id, int offset) throws IOException {
    HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
    MLTextPropertyValue desc00 = new MLTextPropertyValue();
    desc00.addValue(Locale.ENGLISH, "Test null");
    content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
    content00Properties.put(ContentModel.PROP_TITLE, desc00);
    content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test null"));
    content00Properties.put(ContentModel.PROP_CREATED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
    NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test null");
    ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef, content00QName, content00NodeRef, true, 0);
    addNode(h.getCore(), dataModel, 1, 200 + offset, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE, ContentModel.ASPECT_TITLED }, content00Properties, null, "andy", new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef, folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/" + folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
}
Also used : StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 12 with PropertyValue

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

the class LoadCMISData method addSortableNull.

/**
 * @param folder00NodeRef
 * @param rootNodeRef
 * @param baseFolderNodeRef
 * @param baseFolderQName
 * @param folder00QName
 * @param date1
 * @param id
 * @param offset
 * @throws IOException
 */
private void addSortableNull(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName, Date date1, String id, int offset) throws IOException {
    HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
    MLTextPropertyValue desc00 = new MLTextPropertyValue();
    desc00.addValue(Locale.ENGLISH, "Test null");
    content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
    content00Properties.put(ContentModel.PROP_TITLE, desc00);
    content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test null"));
    content00Properties.put(ContentModel.PROP_CREATED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
    NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test null");
    ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef, content00QName, content00NodeRef, true, 0);
    addNode(h.getCore(), dataModel, 1, 200 + offset, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE, ContentModel.ASPECT_TITLED }, content00Properties, null, "andy", new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef, folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/" + folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
}
Also used : StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) 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)

Example 13 with PropertyValue

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

the class LoadCMISData method addSortableNode.

protected void addSortableNode(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName, Date date1, int position) throws IOException {
    HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
    MLTextPropertyValue desc00 = new MLTextPropertyValue();
    desc00.addValue(Locale.ENGLISH, "Test " + position);
    content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
    content00Properties.put(ContentModel.PROP_TITLE, desc00);
    content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test " + position));
    content00Properties.put(ContentModel.PROP_CREATED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
    StringPropertyValue single = new StringPropertyValue(orderable[position]);
    content00Properties.put(singleTextUntokenised, single);
    content00Properties.put(singleTextTokenised, single);
    content00Properties.put(singleTextBoth, single);
    MultiPropertyValue multi = new MultiPropertyValue();
    multi.addValue(single);
    multi.addValue(new StringPropertyValue(orderable[position + 1]));
    content00Properties.put(multipleTextUntokenised, multi);
    content00Properties.put(multipleTextTokenised, multi);
    content00Properties.put(multipleTextBoth, multi);
    content00Properties.put(singleMLTextUntokenised, makeMLText(position));
    content00Properties.put(singleMLTextTokenised, makeMLText(position));
    content00Properties.put(singleMLTextBoth, makeMLText(position));
    content00Properties.put(multipleMLTextUntokenised, makeMLTextMVP(position));
    content00Properties.put(multipleMLTextTokenised, makeMLTextMVP(position));
    content00Properties.put(multipleMLTextBoth, makeMLTextMVP());
    StringPropertyValue one = new StringPropertyValue("" + (1.1 * position));
    StringPropertyValue two = new StringPropertyValue("" + (2.2 * position));
    MultiPropertyValue multiDec = new MultiPropertyValue();
    multiDec.addValue(one);
    multiDec.addValue(two);
    content00Properties.put(singleFloat, one);
    content00Properties.put(multipleFloat, multiDec);
    content00Properties.put(singleDouble, one);
    content00Properties.put(multipleDouble, multiDec);
    one = new StringPropertyValue("" + (1 * position));
    two = new StringPropertyValue("" + (2 * position));
    MultiPropertyValue multiInt = new MultiPropertyValue();
    multiInt.addValue(one);
    multiInt.addValue(two);
    content00Properties.put(singleInteger, one);
    content00Properties.put(multipleInteger, multiInt);
    content00Properties.put(singleLong, one);
    content00Properties.put(multipleLong, multiInt);
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date1);
    cal.add(Calendar.DAY_OF_MONTH, position);
    Date newdate1 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, -1);
    cal.add(Calendar.DAY_OF_MONTH, 2);
    Date date2 = cal.getTime();
    StringPropertyValue d1 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, newdate1));
    StringPropertyValue d2 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date2));
    MultiPropertyValue multiDate = new MultiPropertyValue();
    multiDate.addValue(d1);
    multiDate.addValue(d2);
    content00Properties.put(singleDate, d1);
    content00Properties.put(multipleDate, multiDate);
    content00Properties.put(singleDatetime, d1);
    content00Properties.put(multipleDatetime, multiDate);
    StringPropertyValue b = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, position % 2 == 0 ? true : false));
    StringPropertyValue bTrue = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, true));
    StringPropertyValue bFalse = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, false));
    MultiPropertyValue multiBool = new MultiPropertyValue();
    multiBool.addValue(bTrue);
    multiBool.addValue(bFalse);
    content00Properties.put(singleBoolean, b);
    content00Properties.put(multipleBoolean, multiBool);
    NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test " + position);
    ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef, content00QName, content00NodeRef, true, 0);
    addNode(h.getCore(), dataModel, 1, 1000 + position, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE, ContentModel.ASPECT_TITLED }, content00Properties, null, "andy", new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef, folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/" + folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
}
Also used : StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) StoreRef(org.alfresco.service.cmr.repository.StoreRef) HashMap(java.util.HashMap) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) QName(org.alfresco.service.namespace.QName) 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) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Date(java.util.Date) NodeRef(org.alfresco.service.cmr.repository.NodeRef) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue)

Example 14 with PropertyValue

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

the class AuthDataLoad method setup.

@BeforeClass
public static void setup() throws Exception {
    // Start test haness
    initAlfrescoCore("schema.xml");
    // Root
    NodeRef rootNodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    addStoreRoot(h.getCore(), dataModel, rootNodeRef, 1, 1, 1, 1);
    // rsp.add("StoreRootNode", 1);
    // Base
    HashMap<QName, PropertyValue> baseFolderProperties = new HashMap<QName, PropertyValue>();
    baseFolderProperties.put(ContentModel.PROP_NAME, new StringPropertyValue("Base Folder"));
    NodeRef baseFolderNodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    QName baseFolderQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "baseFolder");
    ChildAssociationRef n01CAR = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, rootNodeRef, baseFolderQName, baseFolderNodeRef, true, 0);
    addNode(h.getCore(), dataModel, 1, 2, 1, ContentModel.TYPE_FOLDER, null, baseFolderProperties, null, "andy", new ChildAssociationRef[] { n01CAR }, new NodeRef[] { rootNodeRef }, new String[] { "/" + baseFolderQName.toString() }, baseFolderNodeRef, true);
    // Folders
    HashMap<QName, PropertyValue> folder00Properties = new HashMap<QName, PropertyValue>();
    folder00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Folder 0"));
    NodeRef folder00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
    QName folder00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Folder 0");
    ChildAssociationRef folder00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, baseFolderNodeRef, folder00QName, folder00NodeRef, true, 0);
    addNode(h.getCore(), dataModel, 1, 3, 1, ContentModel.TYPE_FOLDER, null, folder00Properties, null, "andy", new ChildAssociationRef[] { folder00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef }, new String[] { "/" + baseFolderQName.toString() + "/" + folder00QName.toString() }, folder00NodeRef, true);
    for (long i = 0; i < count; i++) {
        addAcl(h.getCore(), dataModel, 10 + (int) i, 10 + (int) i, (int) (i % maxReader), (int) maxReader);
        HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
        MLTextPropertyValue desc00 = new MLTextPropertyValue();
        desc00.addValue(Locale.ENGLISH, "Doc " + i);
        desc00.addValue(Locale.US, "Doc " + i);
        content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
        content00Properties.put(ContentModel.PROP_TITLE, desc00);
        content00Properties.put(ContentModel.PROP_CONTENT, new ContentPropertyValue(Locale.UK, 0l, "UTF-8", "text/plain", null));
        content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Doc " + i));
        content00Properties.put(ContentModel.PROP_CREATOR, new StringPropertyValue("Test"));
        content00Properties.put(ContentModel.PROP_MODIFIER, new StringPropertyValue("Test"));
        content00Properties.put(ContentModel.PROP_VERSION_LABEL, new StringPropertyValue("1.0"));
        content00Properties.put(ContentModel.PROP_OWNER, new StringPropertyValue("Test"));
        Date date00 = new Date();
        content00Properties.put(ContentModel.PROP_CREATED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date00)));
        content00Properties.put(ContentModel.PROP_MODIFIED, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date00)));
        HashMap<QName, String> content00Content = new HashMap<QName, String>();
        content00Content.put(ContentModel.PROP_CONTENT, "Test doc number " + i);
        NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
        QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Doc-" + i);
        ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef, content00QName, content00NodeRef, true, 0);
        addNode(h.getCore(), dataModel, 1, 10 + (int) i, 10 + (int) i, ContentModel.TYPE_CONTENT, new QName[] { ContentModel.ASPECT_OWNABLE, ContentModel.ASPECT_TITLED }, content00Properties, content00Content, "andy", new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef, folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/" + folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, false);
    }
    h.getCore().getUpdateHandler().commit(new CommitUpdateCommand(req(), false));
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) CommitUpdateCommand(org.apache.solr.update.CommitUpdateCommand) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) 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 15 with PropertyValue

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

the class SolrInformationServer method recreateSolrDoc.

private SolrInputDocument recreateSolrDoc(long dbId, String tenant) throws AuthenticationException, IOException, JSONException {
    NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
    nmdp.setFromNodeId(dbId);
    nmdp.setToNodeId(dbId);
    List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE);
    SolrInputDocument newDoc = null;
    if (!nodeMetaDatas.isEmpty()) {
        NodeMetaData nodeMetaData = nodeMetaDatas.get(0);
        newDoc = createNewDoc(nodeMetaData, DOC_TYPE_NODE);
        addFieldsToDoc(nodeMetaData, newDoc);
        boolean isContentIndexedForNode = isContentIndexedForNode(nodeMetaData.getProperties());
        Map<QName, PropertyValue> properties = nodeMetaData.getProperties();
        // Cached doc is null for this method because it is a recreate after a cache miss.
        addPropertiesToDoc(properties, isContentIndexedForNode, newDoc, null, transformContent);
    } else {
        // we get an empty list if a node is deleted
        if (log.isDebugEnabled()) {
            log.debug("Failed to recreate Solr doc with tenant [" + tenant + "] and dbId [" + dbId + "], " + "because node not found in repository.");
        }
    }
    return newDoc;
}
Also used : NodeMetaData(org.alfresco.solr.client.NodeMetaData) SolrInputDocument(org.apache.solr.common.SolrInputDocument) QName(org.alfresco.service.namespace.QName) NodeMetaDataParameters(org.alfresco.solr.client.NodeMetaDataParameters) 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)

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