06-20-2018 09:48 AM
I am very new to Alfresco content services and am trying to understand how to go about the below
I have an aspect called orderDetails that has a property called OrderIds. I can have have one or more orderIds associated with a document.
1. What should the data type of orderIds property be so that it can store many values?
2. How best can I implement this so that I should also be able to search for all documents for a given OrderID
Doc 1 - OrderID 1, 3, 5, 8
Doc 2 - OrderID 1, 2, 3, 6, 7
Doc 3 - OrderID 3,4,7
If I search for document for orderID 7 then I should be able to fetch Doc 2 and Doc 3.
06-21-2018 03:11 AM
Jeff Potts published a great tutorial to build Content Models, available at https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#creating...
Basically you have to define an association to gather all documents together.
06-21-2018 05:20 AM
As long as you are only recording an "orderID" as a simple text value, you do not need to use associations. A single d:text property with multiple set to true would suffice to allow you to store (n)one to many orderID values for each document and search for them using advanced search capabilities / FTS.
An association will become necessary, when you want to record additional data relating to the order itself, and want to avoid data redundancy. In that case you might want to create individual nodes per order (with its orderID + other metadata) and link documents to those order nodes via associations. Bear in mind that searching via associations is not as easy as simple metadata search - essentially, you can search for the order via the orderID, and then use the association (in a second step) to navigate to all documents associated with that particular order.
06-22-2018 07:28 AM
Axel Faust - In my case I am not going to store only one OrderID. My scenario has changed a bit over the last day. I would need to store multiple pairs of orderIds and customer Ids. I would presume I need to define a custom type that has two text properties that can store orderId and customerId. I would then need to define this custom type as property in my model with multiple set to true. I hope this approach is correct?
Doc 1 - {OrderID 1, Customer ID 100}, {OrderID 3, Customer ID 101}
Doc 2 - {OrderID 2, Customer ID 100},{OrderID 1, Customer ID 101},{OrderID 1, Customer ID 102}
Doc 3 - {OrderID 1, Customer ID 100}
Also, how does alfresco behave in terms of searches when I use custom data types? In the above case, If I search for a orderId, would alfresco be able to search within multiple order Ids within the custom data type and return appropriate matches.
Example search
If I search for OrderId 101, then I would expect to get Doc 1 and Doc 2.
Thanks
06-23-2018 01:48 PM
And that is where it becomes complicated and you actually can no longer use properties. You cannot declare a property to be of a complex type - only simple value types (text, numeric, date, boolean) are supported. If you have data in such a way as you describe, you pretty much only have the option of modelling them as separate nodes (which you'd already do by defining the custom type) and then using associations (like Angel Borroy pointed out) to group the documents referring to the same order. You can forget about being able to search for documents based on orderID + customerID in that case, since searches in Alfresco only cover properties / metadata. You would have to perform a custom, two-step search operation to first search for orders and then navigate their associations back to the documents linked to them.
Explore our Alfresco products with the links below. Use labels to filter content by product module.