Search in sources :

Example 11 with MLTextPropertyValue

use of org.alfresco.solr.client.MLTextPropertyValue 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 12 with MLTextPropertyValue

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

the class SolrInformationServer method addPropertiesToDoc.

static void addPropertiesToDoc(Map<QName, PropertyValue> properties, boolean isContentIndexedForNode, SolrInputDocument newDoc, SolrInputDocument cachedDoc, boolean transformContentFlag) throws IOException {
    for (QName propertyQName : properties.keySet()) {
        newDoc.addField(FIELD_PROPERTIES, propertyQName.toString());
        newDoc.addField(FIELD_PROPERTIES, propertyQName.getPrefixString());
        PropertyValue value = properties.get(propertyQName);
        // System.out.println("####### indexing prop:"+propertyQName.toString()+":"+value.toString());
        if (value != null) {
            if (value instanceof StringPropertyValue) {
                for (FieldInstance field : AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(propertyQName).getFields()) {
                    // System.out.println("####### field:"+field.getField()+":"+value.toString());
                    addStringPropertyToDoc(newDoc, field, (StringPropertyValue) value, properties);
                }
            } else if (value instanceof MLTextPropertyValue) {
                for (FieldInstance field : AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(propertyQName).getFields()) {
                    addMLTextPropertyToDoc(newDoc, field, (MLTextPropertyValue) value);
                }
            } else if (value instanceof ContentPropertyValue) {
                boolean transform = transformContentFlag;
                if (!isContentIndexedForNode) {
                    transform = false;
                }
                addContentPropertyToDocUsingCache(newDoc, cachedDoc, propertyQName, (ContentPropertyValue) value, transform);
            } else if (value instanceof MultiPropertyValue) {
                MultiPropertyValue typedValue = (MultiPropertyValue) value;
                for (PropertyValue singleValue : typedValue.getValues()) {
                    if (singleValue instanceof StringPropertyValue) {
                        for (FieldInstance field : AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(propertyQName).getFields()) {
                            addStringPropertyToDoc(newDoc, field, (StringPropertyValue) singleValue, properties);
                        }
                    } else if (singleValue instanceof MLTextPropertyValue) {
                        for (FieldInstance field : AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(propertyQName).getFields()) {
                            addMLTextPropertyToDoc(newDoc, field, (MLTextPropertyValue) singleValue);
                        }
                    } else if (singleValue instanceof ContentPropertyValue) {
                        boolean transform = transformContentFlag;
                        if (!isContentIndexedForNode) {
                            transform = false;
                        }
                        addContentPropertyToDocUsingCache(newDoc, cachedDoc, propertyQName, (ContentPropertyValue) singleValue, transform);
                    }
                }
            }
        } else {
            // NULL property
            newDoc.addField(FIELD_NULLPROPERTIES, propertyQName.toString());
        }
    }
}
Also used : StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) 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) FieldInstance(org.alfresco.solr.AlfrescoSolrDataModel.FieldInstance) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue)

Aggregations

MLTextPropertyValue (org.alfresco.solr.client.MLTextPropertyValue)12 QName (org.alfresco.service.namespace.QName)10 PropertyValue (org.alfresco.solr.client.PropertyValue)10 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)10 HashMap (java.util.HashMap)8 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)8 NodeRef (org.alfresco.service.cmr.repository.NodeRef)8 StoreRef (org.alfresco.service.cmr.repository.StoreRef)8 ContentPropertyValue (org.alfresco.solr.client.ContentPropertyValue)8 MultiPropertyValue (org.alfresco.solr.client.MultiPropertyValue)8 Date (java.util.Date)5 GregorianCalendar (java.util.GregorianCalendar)3 BeforeClass (org.junit.BeforeClass)3 Locale (java.util.Locale)2 AlfrescoSolrDataModel (org.alfresco.solr.AlfrescoSolrDataModel)2 SolrCore (org.apache.solr.core.SolrCore)2 Calendar (java.util.Calendar)1 Period (org.alfresco.service.cmr.repository.Period)1 Duration (org.alfresco.service.cmr.repository.datatype.Duration)1 FieldInstance (org.alfresco.solr.AlfrescoSolrDataModel.FieldInstance)1