List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:fi.kela.kanta.cda.Purkaja.java
/** * Apumetodi osoitetietojen purkamiseen//from www . ja va2 s . c o m * * @param adddr * AD josta osoitetietoja haetaan * @return OsoiteTO johon lytyneet osoitetiedot on sijoitettu */ protected OsoiteTO puraOsoite(AD addr) { // TODO: Parempi tapa tunnistaa elementit? OsoiteTO osoite = new OsoiteTO(); for (Serializable serializable : addr.getContent()) { if (!(serializable instanceof JAXBElement<?>)) { continue; } JAXBElement<?> element = (JAXBElement<?>) serializable; if (element.getValue() instanceof AdxpStreetAddressLine) { AdxpStreetAddressLine value = (AdxpStreetAddressLine) element.getValue(); if (value.getContent() != null && !value.getContent().isEmpty()) { osoite.setKatuosoite((String) value.getContent().get(0)); } } else if (element.getValue() instanceof AdxpPostalCode) { AdxpPostalCode value = (AdxpPostalCode) element.getValue(); if (value.getContent() != null && !value.getContent().isEmpty()) { osoite.setPostinumero((String) value.getContent().get(0)); } } else if (element.getValue() instanceof AdxpCity) { AdxpCity value = (AdxpCity) element.getValue(); if (value.getContent() != null && !value.getContent().isEmpty()) { osoite.setPostitoimipaikka((String) value.getContent().get(0)); } } else if (element.getValue() instanceof AdxpCountry) { AdxpCountry value = (AdxpCountry) element.getValue(); if (value.getContent() != null && !value.getContent().isEmpty()) { osoite.setMaa((String) value.getContent().get(0)); } } } return osoite; }
From source file:de.extra.client.core.plugin.dummies.DummyQueryDataResponceOutputPlugin.java
/** * Liefert QueryArguments als List/*ww w. ja va2 s . com*/ * * @return */ private List<String> getQueryArguments(final RequestTransport requestXml) { final RequestTransportBody transportBody = requestXml.getTransportBody(); Assert.notNull(transportBody, "ResponseTransportBody is null"); final DataType data = transportBody.getData(); Assert.notNull(data, "TransportData is null"); final ElementSequenceType elementSequence = data.getElementSequence(); Assert.notNull(elementSequence, "TransportData.elementSequence is null"); final List<Object> any = elementSequence.getAny(); Assert.notNull(any, "ElementSequence is empty is null"); Assert.isTrue(any.size() == 1, "ElementSequense beinhaltet mehr als ein Element"); final Object dataRequestObject = any.get(0); Assert.isAssignable(DataRequest.class, dataRequestObject.getClass(), "Unexpectede ElementSequence entry" + dataRequestObject.getClass() + " Expected DataRequest."); final DataRequest dataRequest = (DataRequest) dataRequestObject; final DataRequestQuery query = dataRequest.getQuery(); Assert.notNull(query, "Query is null"); final List<DataRequestArgument> argument = query.getArgument(); Assert.notNull(argument, "DataRequestArgument List is null"); // Assert.isTrue(argument.size() == 1, // "DataRequestArgument List beinhaltet mehr als ein Element"); final DataRequestArgument dataRequestArgument = argument.get(0); Assert.notNull(dataRequestArgument, "DataRequestArgument is null"); final List<JAXBElement<?>> dataRequestArgumentContent = dataRequestArgument.getContent(); Assert.notNull(dataRequestArgumentContent, "DataRequestArgument.content is null"); Assert.isTrue(dataRequestArgumentContent.size() == 1, "DataRequestArgument.content beinhaltet mehr als ein Element"); final JAXBElement<?> jaxbElement = dataRequestArgumentContent.get(0); // TODO MAXRESP (06.11.12) boolean assignableOperand = false; final Object operandSetObject = jaxbElement.getValue(); final List<String> queryArgumentList = new ArrayList<String>(); // OperandSet oder Operand? if (operandSetObject.getClass().isAssignableFrom(OperandSet.class)) { assignableOperand = true; final OperandSet operandSet = (OperandSet) operandSetObject; final List<Operand> operandEQ = operandSet.getEQ(); Assert.notNull(operandEQ, "operandEQ is null"); Assert.notEmpty(operandEQ, "operandEQ is empty"); for (final Operand operand : operandEQ) { final String operandValue = operand.getValue(); queryArgumentList.add(operandValue); } } else if (operandSetObject.getClass().isAssignableFrom(Operand.class)) { // Fr Fachverfahren 'Sterbedaten Abgleich'! // Als OperandValue wird die maximale ResponseId erwartet (z.B. 31) // Als Dummy Server Antwort werden drei aufeinanderfolgende ID'S // (z.B. 32,33,34) generiert assignableOperand = true; final Operand operand = (Operand) operandSetObject; final String operandValue = operand.getValue(); try { final long operandValueAsLong = Long.parseLong(operandValue); for (long respId = operandValueAsLong + 1; respId <= operandValueAsLong + 3; respId++) { queryArgumentList.add(String.valueOf(respId)); } } catch (final NumberFormatException ex) { // Anderes Fachverfahren? queryArgumentList.add(operandValue); } } Assert.isTrue(assignableOperand, "Unexpected dataRequestArgumentContent entry" + dataRequestObject.getClass() + " Expected OperandSet or Operand."); return queryArgumentList; }
From source file:eu.dasish.annotation.backend.rest.AnnotationResourceTest.java
/** * Test of createAnnotation method, of class AnnotationResource. *///from w ww . j av a 2 s. c o m @Test public void testCreateAnnotation() throws IOException, NotInDataBaseException { System.out.println("test createAnnotation"); final Annotation annotationToAdd = (new TestInstances("/api")).getAnnotationToAdd(); final Number newAnnotationID = 5; final Annotation addedAnnotation = (new ObjectFactory()).createAnnotation(annotationToAdd).getValue(); String externalId = Helpers.generateUUID().toString(); addedAnnotation.setId(externalId); addedAnnotation.setHref("/backend/api/annotations/" + externalId); addedAnnotation.setOwnerHref("/backend/api/principals/00000000-0000-0000-0000-000000000113"); final ResponseBody mockEnvelope = new ResponseBody(); final Action action = new Action(); final ActionList actionList = new ActionList(); mockEnvelope.setAnnotation(addedAnnotation); mockEnvelope.setActionList(actionList); actionList.getAction().add(action); action.setMessage(AnnotationActionName.CREATE_CACHED_REPRESENTATION.value()); action.setObject("/backend/api/targets/00000000-0000-0000-0000-000000000036"); annotationResource.setHttpServletRequest(mockRequest); mockRequest.setRemoteUser("alice@mail.domain"); mockRequest.setContextPath("/backend"); mockRequest.setServletPath("/api"); mockeryRest.checking(new Expectations() { { oneOf(mockDbDispatcher).setResourcesPaths("/backend/api"); oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("alice@mail.domain"); will(returnValue(3)); oneOf(mockDbDispatcher).addPrincipalsAnnotation(3, annotationToAdd); will(returnValue(newAnnotationID)); oneOf(mockDbDispatcher).getAnnotation(newAnnotationID); will(returnValue(addedAnnotation)); oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(newAnnotationID); will(returnValue(mockEnvelope)); } }); JAXBElement<ResponseBody> result = annotationResource.createAnnotation(annotationToAdd); Annotation newAnnotation = result.getValue().getAnnotation(); String actionName = result.getValue().getActionList().getAction().get(0).getMessage(); assertEquals(addedAnnotation.getOwnerHref(), newAnnotation.getOwnerHref()); assertEquals(addedAnnotation.getId(), newAnnotation.getId()); assertEquals(addedAnnotation.getHref(), newAnnotation.getHref()); assertEquals(addedAnnotation.getHeadline(), newAnnotation.getHeadline()); assertEquals(addedAnnotation.getTargets(), newAnnotation.getTargets()); assertEquals(addedAnnotation.getLastModified(), newAnnotation.getLastModified()); assertEquals(addedAnnotation.getBody(), newAnnotation.getBody()); assertEquals(AnnotationActionName.CREATE_CACHED_REPRESENTATION.value(), actionName); assertEquals(Access.WRITE, addedAnnotation.getPermissions().getPublic()); }
From source file:com.evolveum.midpoint.model.impl.lens.projector.policy.evaluators.AssignmentModificationConstraintEvaluator.java
@Override public <F extends FocusType> EvaluatedPolicyRuleTrigger evaluate( JAXBElement<AssignmentModificationPolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<F> rctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { AssignmentModificationPolicyConstraintType constraint = constraintElement.getValue(); if (!(rctx instanceof AssignmentPolicyRuleEvaluationContext)) { return null; }// ww w. j a v a 2s. com AssignmentPolicyRuleEvaluationContext<F> ctx = (AssignmentPolicyRuleEvaluationContext<F>) rctx; if (!ctx.isDirect || !operationMatches(constraint, ctx.inPlus, ctx.inZero, ctx.inMinus) || !relationMatches(constraint, ctx) || !pathsMatch(constraint, ctx) || !expressionPasses(constraintElement, ctx, result)) { return null; } // TODO check modifications return new EvaluatedModificationTrigger(PolicyConstraintKindType.ASSIGNMENT_MODIFICATION, constraint, createMessage(constraintElement, ctx, result), createShortMessage(constraintElement, ctx, result)); }
From source file:com.fluxit.camel.component.n4.N4Producer.java
/** * TODO JAVADOC!!!!/*w w w . jav a 2 s . c o m*/ */ public void process(Exchange exchange) throws Exception { Object resultBody = null; LOG.debug("Exchange en N4 Producer: {0}", exchange.getIn().getBody()); XsltUriResolver uriResolver = new XsltUriResolver(exchange.getContext().getClassResolver(), null); if (endpoint.getUriXSLTInput() != null && endpoint.getTransformerForInput() != null) { LOG.trace("Creando transformer para input de XSLT"); Transformer transformer = TransformerFactory.newInstance() .newTransformer(uriResolver.resolve(endpoint.getUriXSLTInput(), null)); // omito la declaracion de XML en la salida transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); endpoint.setTransformerForInput(transformer); } if (endpoint.getProviderType().equals(N4Endpoint.FILTER_PROVIDER)) { String httpQuery = ""; if (endpoint.getUriMapInput() != null) { Object body = exchange.getIn().getBody(); MapperURITransformForFilter inputTransformer = new MapperURITransformForFilter(); httpQuery = inputTransformer.transformURI(endpoint.getUriMapInput(), body); } else if (endpoint.getUriXSLTInput() != null) { if ((exchange.getIn().getBody() instanceof List)) { throw new IllegalArgumentException( "Como cuerpo del mensaje existe una lista pero no existe mapa de conversion en la property uriMapInput "); } // TODO chequear que si viene en modo POJO no se puede hacer StringWriter writer = new StringWriter(); Source body = exchange.getIn().getBody(Source.class); endpoint.getTransformerForInput().transform(body, new StreamResult(writer)); httpQuery = writer.toString(); LOG.debug("La query luego de la transformacion XSLT es {0}", httpQuery); } // TODO VER QU USAR PARA CREAR LA URL CON UN BUILDER // FIXME CAMBIAR LOS VALORES DE SCOPE POR PROPERTIES DEL SISTEMA String url = new StringBuffer(endpoint.getN4EndpointURI()).append("?").append("filtername=") .append(endpoint.getFilterName()).append("&").append(httpQuery) .append("&operatorId=ICT&complexId=TPL&facilityId=PLP&yardId=ZPB").toString(); LOG.debug("Se invocar a la URL {0} con el usuario {1} y password {2}", url, endpoint.getN4User(), endpoint.getN4Pass()); HttpClient client = createHttpClient(); // Create a method instance. GetMethod method = new GetMethod(url); resultBody = invokeHttp(url, client, method); // TODO hacer la transformacin if (endpoint.getUriXSLTOutput() != null) { if (endpoint.getTransformerForOutput() == null) { LOG.trace("Creando transformer para output de XSLT"); Transformer transformer = TransformerFactory.newInstance() .newTransformer(uriResolver.resolve(endpoint.getUriXSLTOutput(), null)); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); endpoint.setTransformerForOutput(transformer); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); endpoint.getTransformerForOutput().transform(new StreamSource((InputStream) resultBody), new StreamResult(outputStream)); resultBody = new ByteArrayInputStream(outputStream.toByteArray()); // TODO chequear que el defaultCharset este bien LOG.debug("Resultado de la transformacion XSLT de salida: {0}", new String(outputStream.toByteArray(), Charset.defaultCharset())); } // end if de transformacion XSLT output if (endpoint.getClassSerialization() != null) { JAXBElement<?> element = endpoint.getJaxbContext().createUnmarshaller().unmarshal( new StreamSource((InputStream) resultBody), Class.forName(endpoint.getClassSerialization())); Object value = element.getValue(); resultBody = value; } // end if de serializacion } else if (endpoint.getProviderType() == N4Endpoint.GENERIC_WS_PROVIDER) { // TODO hacer todo el procesamiento para el ws generico } exchange.getOut().setBody(resultBody); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.PresentationWSDaoImpl.java
@Override public BlackboardPresentationResponse uploadPresentation(String creatorId, String filename, String description, DataHandler data) {//from w w w. j av a2 s. c o m BlackboardUploadRepositoryContent request = new ObjectFactory().createBlackboardUploadRepositoryContent(); request.setCreatorId(creatorId); request.setDescription(description); request.setFilename(filename); request.setContent(data); JAXBElement<BlackboardUploadRepositoryContent> createUploadRepositoryPresentation = new ObjectFactory() .createUploadRepositoryPresentation(request); @SuppressWarnings("unchecked") JAXBElement<BlackboardPresentationResponseCollection> response = (JAXBElement<BlackboardPresentationResponseCollection>) sasWebServiceOperations .marshalSendAndReceiveToSAS("http://sas.elluminate.com/UploadRepositoryPresentation", createUploadRepositoryPresentation); BlackboardPresentationResponseCollection unwrappedResponse = response.getValue(); return DataAccessUtils.singleResult(unwrappedResponse.getPresentationResponses()); }
From source file:gov.nih.nci.integration.caaers.CaAERSParticipantServiceWSClient.java
/** * Unmarshalls a ParticipantType object from an xml string * //from ww w. ja v a 2 s . co m * @param participantXMLStr - the Participant xml string * @return ParticipantType object * @throws JAXBException - JAXBException */ public ParticipantType parseParticipant(String participantXMLStr) throws JAXBException { final JAXBElement<ParticipantType> jaxbEle = (JAXBElement<ParticipantType>) getUnmarshaller() .unmarshal(new StreamSource(new StringReader(participantXMLStr)), ParticipantType.class); return jaxbEle.getValue(); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.PresentationWSDaoImpl.java
@Override public List<BlackboardPresentationResponse> getRepositoryPresentations(String creatorId, Long presentationId, String description) {/*from w w w. j a va 2s.com*/ BlackboardListRepositoryPresentation request = new ObjectFactory() .createBlackboardListRepositoryPresentation(); if (creatorId == null && presentationId == null && description == null) { throw new IllegalStateException("You must specify at least one piece of criteria"); } if (creatorId != null) { request.setCreatorId(creatorId); } if (presentationId != null) { request.setPresentationId(presentationId); } if (description != null) { request.setDescription(description); } @SuppressWarnings("unchecked") final JAXBElement<BlackboardPresentationResponseCollection> response = (JAXBElement<BlackboardPresentationResponseCollection>) sasWebServiceOperations .marshalSendAndReceiveToSAS("http://sas.elluminate.com/ListRepositoryPresentation", request); final BlackboardPresentationResponseCollection objSessionResponse = (BlackboardPresentationResponseCollection) response .getValue(); return objSessionResponse.getPresentationResponses(); }
From source file:edu.harvard.i2b2.eclipse.plugins.pft.views.PatientDataMessage.java
/** * Function to read value, units and concept code from PFT Service response * Then query Ontology service (stub) for name of concept code * /*from w w w. j a v a2 s . c om*/ * Place name, value/units and concept code in the PFT result table UI * * @param response String containing response returned from PFT web service */ public void doReadConceptCode(String response) throws Exception { try { JAXBUtil jaxbUtil = PFTJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType respMessageType = (ResponseMessageType) jaxbElement.getValue(); // Get response message status ResponseHeaderType responseHeader = respMessageType.getResponseHeader(); String procStatus = responseHeader.getResultStatus().getStatus().getType(); String procMessage = responseHeader.getResultStatus().getStatus().getValue(); if (procStatus.equals("ERROR")) { String name = "Error reported by PFT web Service"; String value_units = ""; String code = procMessage; ResultsTab.getInstance().setItem(name, value_units, code); } else if (procStatus.equals("WARNING")) { String name = "Warning reported by PFT web Service"; String value_units = ""; String code = procMessage; ResultsTab.getInstance().setItem(name, value_units, code); } else { BodyType bodyType = respMessageType.getMessageBody(); JAXBUnWrapHelper helper = new JAXBUnWrapHelper(); PatientDataType patientDataType = (PatientDataType) helper.getObjectByClass(bodyType.getAny(), PatientDataType.class); List<PatientDataType.ObservationFactSet> obsFactSet = patientDataType.getObservationFactSet(); if (obsFactSet != null) { if (obsFactSet.get(0).getObservationFact().size() == 0) { // No PFT results were found by PFT Service log.info("No PFT results were found"); String name = "No PFT results were found"; String value_units = ""; String code = "Please verify that the correct report was entered"; ResultsTab.getInstance().setItem(name, value_units, code); } else { // Loop through results and place in Results tab for (int i = 0; i < (obsFactSet.get(0).getObservationFact().size()); i++) { ObservationFactType obsFactType = obsFactSet.get(0).getObservationFact().get(i); // Do ontology lookup to map concept code to name String conceptName = getCodeInfo(obsFactType); // OntologyServiceLookup lookup = new OntologyServiceLookup(); // String conceptName = lookup.getConceptName(obsFactType.getConceptCd()); String value_units = obsFactType.getNvalNum() + " " + obsFactType.getUnitsCd(); ResultsTab.getInstance().setItem(conceptName, value_units, obsFactType.getConceptCd()); } } } else { log.info("No PFT results were found"); String name = "No PFT results were found"; String value_units = ""; String code = "Please check that the correct report was entered"; ResultsTab.getInstance().setItem(name, value_units, code); } } } catch (Exception e) { log.error("Error unmarshalling PFT response"); String name = "No PFT results were found"; String value_units = ""; String code = "Please check that PFT web service is running"; ResultsTab.getInstance().setItem(name, value_units, code); throw new Exception(e.getMessage()); } }
From source file:com.evolveum.midpoint.model.impl.lens.LensUtil.java
public static <V extends PrismValue, D extends ItemDefinition, F extends FocusType> Mapping<V, D> createFocusMapping( final MappingFactory mappingFactory, final LensContext<F> context, final MappingType mappingType, ObjectType originObject, ObjectDeltaObject<F> focusOdo, AssignmentPathVariables assignmentPathVariables, Integer iteration, String iterationToken, PrismObject<SystemConfigurationType> configuration, XMLGregorianCalendar now, String contextDesc, final Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { Mapping<V, D> mapping = mappingFactory.createMapping(mappingType, contextDesc); if (!mapping.isApplicableToChannel(context.getChannel())) { return null; }/*from ww w . j av a2 s .c o m*/ mapping.setSourceContext(focusOdo); mapping.setTargetContext(context.getFocusContext().getObjectDefinition()); mapping.setRootNode(focusOdo); mapping.addVariableDefinition(ExpressionConstants.VAR_USER, focusOdo); mapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdo); mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION, iteration); mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken); mapping.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, configuration); addAssignmentPathVariables(mapping, assignmentPathVariables); mapping.setOriginType(OriginType.USER_POLICY); mapping.setOriginObject(originObject); mapping.setNow(now); ItemPath itemPath = mapping.getOutputPath(); if (itemPath == null) { // no output element, i.e. this is a "validation mapping" return mapping; } PrismObject<F> focusNew = focusOdo.getNewObject(); if (focusNew != null) { Item<V, D> existingUserItem = (Item<V, D>) focusNew.findItem(itemPath); if (existingUserItem != null && !existingUserItem.isEmpty() && mapping.getStrength() == MappingStrengthType.WEAK) { // This valueConstruction only applies if the property does not have a value yet. // ... but it does return null; } } StringPolicyResolver stringPolicyResolver = new StringPolicyResolver() { private ItemPath outputPath; private ItemDefinition outputDefinition; @Override public void setOutputPath(ItemPath outputPath) { this.outputPath = outputPath; } @Override public void setOutputDefinition(ItemDefinition outputDefinition) { this.outputDefinition = outputDefinition; } @Override public StringPolicyType resolve() { if (outputDefinition.getName().equals(PasswordType.F_VALUE)) { ValuePolicyType passwordPolicy = context.getEffectivePasswordPolicy(); if (passwordPolicy == null) { return null; } return passwordPolicy.getStringPolicy(); } if (mappingType.getExpression() != null) { List<JAXBElement<?>> evaluators = mappingType.getExpression().getExpressionEvaluator(); if (evaluators != null) { for (JAXBElement jaxbEvaluator : evaluators) { Object object = jaxbEvaluator.getValue(); if (object != null && object instanceof GenerateExpressionEvaluatorType && ((GenerateExpressionEvaluatorType) object).getValuePolicyRef() != null) { ObjectReferenceType ref = ((GenerateExpressionEvaluatorType) object) .getValuePolicyRef(); try { ValuePolicyType valuePolicyType = mappingFactory.getObjectResolver().resolve( ref, ValuePolicyType.class, null, "resolving value policy for generate attribute " + outputDefinition.getName() + " value", task, new OperationResult("Resolving value policy")); if (valuePolicyType != null) { return valuePolicyType.getStringPolicy(); } } catch (Exception ex) { throw new SystemException(ex.getMessage(), ex); } } } } } return null; } }; mapping.setStringPolicyResolver(stringPolicyResolver); return mapping; }