use of org.alfresco.solr.client.ContentPropertyValue 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));
}
use of org.alfresco.solr.client.ContentPropertyValue 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());
}
}
}
Aggregations