use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FondsImportService method createFondsAssociatedWithFonds.
/**
*
* Persists a new fonds object to the database, that is associated with a parent fonds object. It's assumed the
* caller has a valid fonds object. Minimal error checking occurs here.
*
* First we try to locate the parent. If the parent does not exist a NoarkEntityNotFoundException exception is
* thrown
*
* @param childFonds incoming fonds object with some values set
* @param parentFondsSystemId The systemId of the parent fonds
* @return the newly persisted fonds object
*/
@Override
public Fonds createFondsAssociatedWithFonds(String parentFondsSystemId, Fonds childFonds) {
Fonds persistedChildFonds = null;
Fonds parentFonds = fondsRepository.findBySystemIdOrderBySystemId(parentFondsSystemId);
if (parentFonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + parentFondsSystemId + " when " + "trying to associate a child fonds with a parent fonds";
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (parentFonds.getReferenceSeries() != null) {
String info = INFO_INVALID_STRUCTURE + " Cannot associate a new child fonds with a fonds that has " + "one or more series " + parentFondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
childFonds.setReferenceParentFonds(parentFonds);
persistedChildFonds = this.createNewFonds(childFonds);
}
return persistedChildFonds;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class RecordImportService method createDocumentDescriptionAssociatedWithRecord.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRecord(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
Record record = recordRepository.findBySystemIdOrderBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new TreeSet<>();
documentDescription.setReferenceRecord(records);
}
records.add(record);
persistedDocumentDescription = documentDescriptionImportService.save(documentDescription);
}
return persistedDocumentDescription;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryImportService method createDocumentDescriptionAssociatedWithRegistryEntry.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
RegistryEntry registryEntry = registryEntryRepository.findBySystemIdOrderBySystemId(systemID);
if (registryEntry == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using registryEntrySystemId " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new TreeSet<>();
documentDescription.setReferenceRecord(records);
}
records.add(registryEntry);
persistedDocumentDescription = documentDescriptionImportService.save(documentDescription);
}
return persistedDocumentDescription;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesImportService method createCaseFileAssociatedWithSeries.
// All CREATE operations
@Override
public CaseFile createCaseFileAssociatedWithSeries(String seriesSystemId, CaseFile caseFile) {
CaseFile persistedFile = null;
Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
if (series == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
caseFile.setReferenceSeries(series);
persistedFile = caseFileImportService.save(caseFile);
}
return persistedFile;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class PrecedenceService method getPrecedenceOrThrow.
/**
* Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
* If you call this, be aware that you will only ever get a valid Precedence back. If there is no valid
* Precedence, an exception is thrown
*
* @param precedenceSystemId
* @return
*/
protected Precedence getPrecedenceOrThrow(@NotNull String precedenceSystemId) {
Precedence precedence = precedenceRepository.findBySystemIdOrderBySystemId(precedenceSystemId);
if (precedence == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Precedence, using systemId " + precedenceSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return precedence;
}
Aggregations