use of nikita.common.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method findAllRegistryEntry.
// Get all registryEntry
// GET [contextPath][api]/casehandling/journalpost/
// http://rel.kxml.no/noark5/v4/api/sakarkiv/journalpost/
@ApiOperation(value = "Retrieves multiple RegistryEntry entities limited by ownership rights", notes = "The field skip" + "tells how many RegistryEntry rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry found", response = RegistryEntryHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findAllRegistryEntry(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas((ArrayList<INikitaEntity>) (ArrayList) registryEntryService.findRegistryEntryByOwnerPaginated(top, skip));
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
use of nikita.common.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.common.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.common.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.common.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;
}
Aggregations