As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Good afternoon. I got acquainted with an example of programming using the built-in classes and services in Alfresco (for example, https://github.com/Redpill-Linpro/alfresco-uploading). About the use of embedded services at the software level in the official documentation did not find.
Question: where can I get acquainted with the full documentation on the development of my modules in Java using the built-in services and classes of Alfresco?
The Alfresco docs actually contain a decent amount of useful documentation about this: Public Java API services | Alfresco Documentation .
What specifically can we help you with? As Mark says, there are a number of resources out there. The docs are good and there are a number of books that cover this topic as well as tutorials and blog posts.
I'm not sure what you're looking for beyond general pointers to resources. Maybe that's all you need?
Thank you Jeff and Mark. I got acquainted with this documentation, but I did not find a suitable solution in it. The task in the next - it is necessary to conduct end-to-end numbering of documents that participated in certain business processes. I have thoughts of doing this through service in these processes. I plan to store the numbering data as a property of the document model. There was a question - how to determine the latest number to generate the following?
One thing I've done in the past is create a folder in the Data Dictionary and then place objects in it that keep track of my numbering. You can use properties on the objects to store the number sequence information or you can use JSON to do that and write it as the content of the object.
Then, when you need to know what the next number is you can do a query to find your numbering object, use its property values to determine the next number, update the object, and return.
All of that logic should be in a "NumberingService" class which is a Spring bean you will configure in a Spring context XML file. Any other classes, like web scripts or behaviors, that need to do numbering, will inject the NumberingService as a dependency.
This is a common pattern that you will find throughout those tutorials and many add-ons.
Thank you, Jeff. Your advice is very useful. I reasoned in the same direction - use a separate folder, and use my written service to generate a number, injection of service is carried out through Spring.
But I do not quite understand how to track the last assigned document number? How to search for the last assigned number?
It depends on how you decide to persist the sequence. One way is to extend the content model to create a new type, let's say it is called Sequence. The type could have a property called "sequenceNumber". I would suggest also a property called "sequenceKey" so that you could maintain multiple sequences if needed. Then you can just do a search to find the instance of Sequence with the key you need and grab the sequenceNumber property from it.
For example, you might do something like...
public getNextNumber(String key) {
final NodeRef seqNode = getSequenceNode(key); long value = (Long) nodeService.getProperty(seqNode, CoreModel.PROP_VALUE);
final long incrValue = value + 1; AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { nodeService.setProperty(seqNode, CoreModel.PROP_VALUE, incrValue); return ""; } });
return value;
}
private NodeRef getSequenceNode(String key) { String query = "TYPE:\"sc:autoNumberSequence\" AND sc:key:\"" + key + "\""; ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, query); NodeRef sequenceNode = null; if (rs.length() == 0) { sequenceNode = createSequenceNode(key); } else if (rs.length() > 1) { logger.warn("More than one auto number sequence node found for: " + key); sequenceNode = rs.getNodeRef(0); } else { sequenceNode = rs.getNodeRef(0); }
return sequenceNode;}