Updated tutorial: Working with Custom Content Types in Alfresco

The Working with Custom Content Types tutorial has just been given a major revision. I’ve updated it to match the refactored code. Here is a summary of the high-level changes:

  • Instructions now assume you are using the Alfresco Maven SDK. If you haven’t played with the Alfresco Maven SDK yet, check out my recently published tutorial on the subject.
  • Removed all mention of Alfresco Explorer. The tutorial is now exclusively focused on Alfresco Share for the user interface part.
  • Removed all mention of the Alfresco Web Services API. The tutorial is now exclusively focused on CMIS as the preferred API for performing CRUD functions against the Alfresco repository.

The code and the tutorial text reside in GitHub. If you find issues or make improvements, please fork the repository and send me a pull request.

15 comments

  1. Todd Hivnor says:

    Jeff, this this tutorial has been really helpful. Thank you so much for sharing.

    I’ve gotten the examples all working, and done some content modeling of my own. Now I’m hitting the deeper design questions.

    In my problem domain, we of course have many documents. But we also have a lot of non-document entities, with interrelations between them. For example we have projects and clients. There is a many-to-many relationship between documents and projects, and a many-to-many relationship between projects and clients. There is a lot more complexity but I think the many-to-many relationships will prove to be the most challenging.

    With content modeling, I can define content types for my entities, and then establish the appropriate associations. For example it seems natural to establish content types for document, project, and client. Then I can add peer associations between my documents and my projects, and a peer association between my projects and clients.

    The Alfresco documentation around peer associations (aka non-child associations) is giving me pause, however. In particular https://wiki.alfresco.com/wiki/Data_Dictionary_Guide notes: “Alfresco’s search languages do not yet support joins across non-child associations.”

    Also, http://wiki.alfresco.com/wiki/CMIS_Query_Language notes: “capabilityJoin … none – JOIN is not supported”

    I definitely need to be able to say “which documents are used by a certain client?” In SQL terms, I would do a three table join, on clients, projects, and documents.

    I would like to be able save these searches and share them with my co-workers. Ideally, I could present search results from a saved search in a dashlet. But I’m concerned I won’t be able to do any of that, if I really can’t perform queries across peer associations.

    Perhaps I’m just not modeling it correctly. Maybe I should be using child associations, and implementing a behavior on the server which enforces the bi-directionality I want? For example, I suspect I could add a behaviors saying “when A is linked to B, add the corresponding link from B back to A.” And, “when A is unlinked from B, remove the corresponding link from B to A.”

    Or maybe content modeling is not the right approach for my problem domain. Perhaps I need to layer something on top of Alfresco, to manage the relations between clients and projects? I would really hate to go that route. I’m sure there would be challenging to get the user interface to mesh well.

  2. Jeff Potts says:

    Glad you got everything working and that the tutorials are useful to you!

    This is a common problem which can be summarized as, “How do I make Alfresco a little bit more like a relational database?”

    For problems with a lot of relationships I wouldn’t even try. It isn’t meant to do that.

    If you absolutely need to make a single query that would normally make a join, one way to address that problem is to write a behavior that will update a property on the source side of the relationship whenever something on the target side changes. For example, if you have a relationship between a project and a client, you could have a field on the project object that would be set with the client name when that association is created. You’d also potentially want behaviors to change that name if it was changed on the target or remove it entirely if the association is deleted.

    But, once you have that, you can do the query against the project because the client name is set on the object and therefore no join is required.

    You can see how a model with many relationships would get unwieldy and performance could potentially suffer with a large number of behaviors checking all of those associations.

    It is possible that this problem will get addressed by improvements in Solr but I don’t know where that it is on the roadmap or indeed if it will ever happen.

    You might want to log in to #alfresco on freenode IRC and start this discussion to see what others have done to address this.

    Jeff

  3. Todd Hivnor says:

    Thanks for the thoughtful reply. It confirms what I suspected: an SQL mindset is a not good approach to content modeling.

    I’m still not clear on the differences between peer associations and child associations. I understand that child associations do cascaded deletes, and can enforce name uniqueness. But are those really the only differences? Can I create a many-to-many child association?

    On a related note, with folders, can I have one file reside in multiple folders?

    On a different note: In the Share interface, I’ve created two SomeCo Docs, let’s call them DocA and DocB. By Editing the properties for DocA, I can say that DocB is related to DocA. When I view the details page for DocA, I see the Properties | Related Documents: DocB. But I can’t actually click on DocB to open that document up. Is there a way to make that associations navigable in the Share interface?

  4. Santosh Pydisetti says:

    Hi Jeff,
    In Alfresco5 Where exactly Alfresco OOTB models sits ..? and how it’s loaded into alfresco..Can You please explain.

  5. Jeff Potts says:

    Santosh,

    Take a look at my content tutorial. I’ve recently updated it for 5.0.

    For the short answer to your question, the content models are in XML files stored in multiple JAR files that live in WEB-INF/lib.

    Jeff

Comments are closed.