I did it like the following:

  <extension target="org.nuxeo.ecm.core.schema.TypeService"
    point="schema">
    <schema name="my_schema" src="schemas/my_schema.xsd" />
  </extension>

  [ ... ]

  <extension target="org.nuxeo.ecm.core.schema.TypeService"
    point="doctype">
    <doctype name="my_document" extends="Document">
      <schema name="my_schema" />
    </doctype>

  </extension>

  [ ... ]

  <extension target
="org.nuxeo.ecm.platform.uidgen.service.UIDGeneratorService"

    point="generators">
    <generator name="my_generator"
      class="org.blablabla.UIDMyDocumentGenerator">
      <propertyName>my_schema:my_uid</propertyName>
      <docType>my_document</docType>
    </generator>
  </extension>


And then, you have to implement UIDMyDocumentGenerator...
something like this:

[ ... ]

public class UIDMyDocumentGenerator extends
AbstractUIDGenerator {

    [ ... ]

    private static final String NFORMAT = "%05d";

    public String getSequenceKey(DocumentModel doc) throws
DocumentException {

        Calendar cal = new GregorianCalendar();
        return Integer.toString(cal.get(Calendar.YEAR));

    }

    public String createUID(DocumentModel doc) throws
DocumentException {

        int index = getNext(doc);
        String n = String.format(NFORMAT, index);
        log.warn(doc);

        final String seqKey = getSequenceKey(doc);

        return seqKey + "/" + n;

    }

}

I hope it helps you build yours.
---
Mailing list: [email protected]
Forum: http://forum.nuxeo.org/f/1/

Reply via email to