/** * The local identity is created using a sequence. If the sequence does not exist, a new one is created * with initial value calculated using the maximum integer for the existing local CV identifiers. * @return The next value available * @throws SequenceCreationException thrown if the sequence cannot be created. */ protected String nextLocalIdentifier() throws SequenceCreationException { final IntactContext context = IntactContext.getCurrentInstance(); String prefix = context.getConfig().getLocalCvPrefix(); Integer max = context.getDataContext().getDaoFactory() .getCvObjectDao().getLastCvIdentifierWithPrefix(prefix); if (max == null) max = 0; SequenceManager seqManager = (SequenceManager) context.getSpringContext().getBean("sequenceManager"); seqManager.createSequenceIfNotExists(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ, max+1); String nextIntegerAsString = String.valueOf(seqManager.getNextValueForSequence(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ)); return prefix+":" + StringUtils.leftPad(nextIntegerAsString, 4, "0"); }
/** * The local identity is created using a sequence. If the sequence does not exist, a new one is created * with initial value calculated using the maximum integer for the existing local CV identifiers. * @return The next value available * @throws SequenceCreationException thrown if the sequence cannot be created. */ protected String nextLocalIdentifier() throws SequenceCreationException { final IntactContext context = IntactContext.getCurrentInstance(); String prefix = context.getConfig().getLocalCvPrefix(); Integer max = context.getDataContext().getDaoFactory() .getCvObjectDao().getLastCvIdentifierWithPrefix(prefix); if (max == null) max = 0; SequenceManager seqManager = (SequenceManager) context.getSpringContext().getBean("sequenceManager"); seqManager.createSequenceIfNotExists(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ, max+1); String nextIntegerAsString = String.valueOf(seqManager.getNextValueForSequence(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ)); return prefix+":" + StringUtils.leftPad(nextIntegerAsString, 4, "0"); }