use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method findRegistryEntryByOwnerPaginated.
// All READ operations
public List<RegistryEntry> findRegistryEntryByOwnerPaginated(Integer top, Integer skip) {
if (top == null || top > maxPageSize) {
top = maxPageSize;
}
if (skip == null) {
skip = 0;
}
String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<RegistryEntry> criteriaQuery = criteriaBuilder.createQuery(RegistryEntry.class);
Root<RegistryEntry> from = criteriaQuery.from(RegistryEntry.class);
CriteriaQuery<RegistryEntry> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<RegistryEntry> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(top);
return typedQuery.getResultList();
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method createDocumentDescriptionAssociatedWithRegistryEntry.
/*
TODO: Temp disabled!
private void associateCorrespondencePartTypeWithCorrespondencePart(@NotNull CorrespondencePart correspondencePart) {
CorrespondencePartType incomingCorrespondencePartType = correspondencePart.getCorrespondencePartType();
// It should never get this far with a null value
// It should be rejected at controller level
// The incoming CorrespondencePartType will not have @id field set. Therefore, we have to look it up
// in the database and make sure the proper CorrespondencePartType is associated with the CorrespondencePart
if (incomingCorrespondencePartType != null && incomingCorrespondencePartType.getCode() != null) {
CorrespondencePartType actualCorrespondencePartType =
correspondencePartTypeRepository.findByCode(incomingCorrespondencePartType.getCode());
if (actualCorrespondencePartType != null) {
correspondencePart.setCorrespondencePartType(actualCorrespondencePartType);
}
}
}
TODO: Temp disabled!
@Override
public List<CorrespondencePartPerson> getCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartPerson();
}
@Override
public List<CorrespondencePartInternal> getCorrespondencePartInternalAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartInternal();
}
@Override
public List<CorrespondencePartUnit> getCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartUnit();
}
*/
/* @Override
public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(
String systemID, CorrespondencePartPerson correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
TODO: Temp disabled!
associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
ContactInformation contactInformation = correspondencePart.getContactInformation();
if (null != contactInformation) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
}
SimpleAddress postalAddress = correspondencePart.getPostalAddress();
if (null != postalAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
}
SimpleAddress residingAddress = correspondencePart.getResidingAddress();
if (null != residingAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(residingAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(residingAddress);
}
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartPerson().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartPerson(correspondencePart);
return null;
}
*/
/*
TODO: Temp disabled!
@Override
public CorrespondencePartInternal createCorrespondencePartInternalAssociatedWithRegistryEntry(
String systemID, CorrespondencePartInternal correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartInternal().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
}
@Override
public CorrespondencePartUnit createCorrespondencePartUnitAssociatedWithRegistryEntry(
String systemID, CorrespondencePartUnit correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
ContactInformation contactInformation = correspondencePart.getContactInformation();
if (null != contactInformation) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
}
SimpleAddress postalAddress = correspondencePart.getPostalAddress();
if (null != postalAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
}
SimpleAddress businessAddress = correspondencePart.getBusinessAddress();
if (null != businessAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(businessAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(businessAddress);
}
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartUnit().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartUnit(correspondencePart);
}
*/
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
// It should always be instaniated ... check this ...
if (records == null) {
records = new ArrayList<>();
documentDescription.setReferenceRecord(records);
}
records.add(registryEntry);
return documentDescriptionService.save(documentDescription);
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String registryEntrySystemId) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(registryEntrySystemId);
registryEntryRepository.delete(registryEntry);
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method getRegistryEntryOrThrow.
/**
* 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 RegistryEntry back. If there is no valid
* RegistryEntry, an exception is thrown
*
* @param registryEntrySystemId
* @return
*/
protected RegistryEntry getRegistryEntryOrThrow(@NotNull String registryEntrySystemId) {
RegistryEntry registryEntry = registryEntryRepository.findBySystemId(registryEntrySystemId);
if (registryEntry == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using systemId " + registryEntrySystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return registryEntry;
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method handleUpdate.
// All UPDATE operations
@Override
public RegistryEntry handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull RegistryEntry incomingRegistryEntry) {
RegistryEntry existingRegistryEntry = getRegistryEntryOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != incomingRegistryEntry.getDescription()) {
existingRegistryEntry.setDescription(incomingRegistryEntry.getDescription());
}
if (null != incomingRegistryEntry.getTitle()) {
existingRegistryEntry.setTitle(incomingRegistryEntry.getTitle());
}
if (null != incomingRegistryEntry.getDocumentMedium()) {
existingRegistryEntry.setDocumentMedium(incomingRegistryEntry.getDocumentMedium());
}
if (null != incomingRegistryEntry.getDocumentDate()) {
existingRegistryEntry.setDocumentDate(incomingRegistryEntry.getDocumentDate());
}
if (null != incomingRegistryEntry.getDueDate()) {
existingRegistryEntry.setDueDate(incomingRegistryEntry.getDueDate());
}
if (null != incomingRegistryEntry.getFreedomAssessmentDate()) {
existingRegistryEntry.setFreedomAssessmentDate(incomingRegistryEntry.getFreedomAssessmentDate());
}
if (null != incomingRegistryEntry.getLoanedDate()) {
existingRegistryEntry.setLoanedDate(incomingRegistryEntry.getLoanedDate());
}
if (null != incomingRegistryEntry.getLoanedTo()) {
existingRegistryEntry.setLoanedTo(incomingRegistryEntry.getLoanedTo());
}
existingRegistryEntry.setVersion(version);
registryEntryRepository.save(existingRegistryEntry);
return existingRegistryEntry;
}
Aggregations