use of nikita.common.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkEntity, HateoasNoarkObject documentDescriptionHateoas, JsonGenerator jgen) throws IOException {
DocumentDescription documentDescription = (DocumentDescription) noarkEntity;
jgen.writeStartObject();
// handle DocumentDescription properties
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentDescription);
if (documentDescription.getDocumentType() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_DOCUMENT_TYPE, documentDescription.getDocumentType());
}
if (documentDescription.getDocumentStatus() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_STATUS, documentDescription.getDocumentStatus());
}
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, documentDescription);
if (documentDescription.getDocumentNumber() != null) {
jgen.writeNumberField(DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER, documentDescription.getDocumentNumber().intValue());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentDescription);
if (documentDescription.getAssociationDate() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATION_DATE, Serialize.formatDate(documentDescription.getAssociationDate()));
}
if (documentDescription.getAssociatedWithRecordAs() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS, documentDescription.getAssociatedWithRecordAs());
}
CommonUtils.Hateoas.Serialize.printComment(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposal(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposalUndertaken(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDeletion(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printScreening(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printClassified(jgen, documentDescription);
if (documentDescription.getStorageLocation() != null) {
jgen.writeStringField(STORAGE_LOCATION, documentDescription.getStorageLocation());
}
CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentDescriptionHateoas.getLinks(documentDescription));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkEntity, HateoasNoarkObject documentDescriptionHateoas, JsonGenerator jgen) throws IOException {
DocumentDescription documentDescription = (DocumentDescription) noarkEntity;
jgen.writeStartObject();
// handle DocumentDescription properties
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentDescription);
if (documentDescription.getDocumentType() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_DOCUMENT_TYPE, documentDescription.getDocumentType());
}
if (documentDescription.getDocumentStatus() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_STATUS, documentDescription.getDocumentStatus());
}
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, documentDescription);
if (documentDescription.getDocumentNumber() != null) {
jgen.writeNumberField(DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER, documentDescription.getDocumentNumber().intValue());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentDescription);
if (documentDescription.getAssociationDate() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATION_DATE, Serialize.formatDate(documentDescription.getAssociationDate()));
}
if (documentDescription.getAssociationDate() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATION_BY, documentDescription.getAssociatedBy());
}
if (documentDescription.getAssociatedWithRecordAs() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS, documentDescription.getAssociatedWithRecordAs());
}
CommonUtils.Hateoas.Serialize.printComment(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposal(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposalUndertaken(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDeletion(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printScreening(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printClassified(jgen, documentDescription);
if (documentDescription.getStorageLocation() != null) {
jgen.writeStringField(STORAGE_LOCATION, documentDescription.getStorageLocation());
}
CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentDescriptionHateoas.getLinks(documentDescription));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class OdataTest method testOdata.
@RequestMapping(method = RequestMethod.GET, value = "arkivstruktur/{\\w*}")
public ResponseEntity<String> testOdata(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws Exception {
String uqueryString = request.getQueryString();
String decoded = URLDecoder.decode(uqueryString, UTF_8);
StringBuffer originalRequest = request.getRequestURL();
originalRequest.append("?" + decoded);
CharStream stream = CharStreams.fromString(originalRequest.toString());
ODataLexer lexer = new ODataLexer(stream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ODataParser parser = new ODataParser(tokens);
ParseTree tree = parser.odataURL();
ParseTreeWalker walker = new ParseTreeWalker();
// Make the HQL Statement
NikitaODataToHQLWalker hqlWalker = new NikitaODataToHQLWalker();
walker.walk(hqlWalker, tree);
Session session = entityManager.unwrap(org.hibernate.Session.class);
Query query = hqlWalker.getHqlStatment(session);
String queryString = query.getQueryString();
System.out.println(queryString);
List<NoarkEntity> list = query.getResultList();
return ResponseEntity.status(HttpStatus.CREATED).body(list.toString());
}
use of nikita.common.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectHateoasController method deleteDocumentObjectBySystemId.
// Delete a DocumentObject identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentObject entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteDocumentObjectBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentObject to delete", required = true) @PathVariable("systemID") final String systemID) {
DocumentObject documentObject = documentObjectService.findBySystemId(systemID);
NoarkEntity parentEntity = documentObject.chooseParent();
documentObjectService.deleteEntity(systemID);
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof DocumentDescription) {
hateoasNoarkObject = new DocumentDescriptionHateoas(parentEntity);
documentDescriptionHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else if (parentEntity instanceof Record) {
hateoasNoarkObject = new RecordHateoas(parentEntity);
recordHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else {
throw new NikitaException("Internal error. Could process" + request.getRequestURI());
}
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentObject));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
use of nikita.common.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method deleteFileBySystemId.
// Delete a File identified by systemID
// DELETE [contextPath][api]/arkivstruktur/mappe/{systemId}/
@ApiOperation(value = "Deletes a single File entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or File) returned", response = HateoasNoarkObject.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteFileBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to delete", required = true) @PathVariable("systemID") final String systemID) {
File file = fileService.findBySystemId(systemID);
NoarkEntity parentEntity = file.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else if (parentEntity instanceof File) {
hateoasNoarkObject = new FileHateoas(parentEntity);
fileHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else {
throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
}
fileService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, file));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Aggregations