use of com.nedap.archie.rm.support.identification.ObjectId in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method marshallContribution.
@Test
public void marshallContribution() {
List<ObjectRef<? extends ObjectId>> versions = new ArrayList<>();
versions.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
Contribution expected = new Contribution();
expected.setUid(new HierObjectId("bbf60d27-9200-4995-a950-279f889d1050"));
expected.setVersions(versions);
CanonicalJson cut = new CanonicalJson();
String json = cut.marshal(expected);
Contribution actual = cut.unmarshal(json, Contribution.class);
Assert.assertEquals(actual, expected);
}
use of com.nedap.archie.rm.support.identification.ObjectId in project openEHR_SDK by ehrbase.
the class DtoFromCompositionWalker method writeField.
private void writeField(Field field, Object dto, Object value) {
try {
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(field.getName(), dto.getClass());
Object dtoList = value;
if (EnumValueSet.class.isAssignableFrom(field.getType()) && value != null && CodePhrase.class.isAssignableFrom(value.getClass())) {
CodePhrase codePhrase = (CodePhrase) value;
EnumValueSet enumValueSet = Arrays.stream(field.getType().getEnumConstants()).map(o -> (EnumValueSet) o).filter(v -> {
String terminologyId = Optional.ofNullable(codePhrase.getTerminologyId()).map(ObjectId::getValue).orElse(null);
return v.getTerminologyId().equals(terminologyId);
}).filter(v -> v.getCode().equals(codePhrase.getCodeString())).findAny().orElse(null);
dtoList = enumValueSet;
}
if (dtoList instanceof RmPrimitive) {
dtoList = ((RmPrimitive<?>) dtoList).getValue();
}
if (List.class.isAssignableFrom(field.getType())) {
dtoList = propertyDescriptor.getReadMethod().invoke(dto);
if (dtoList == null) {
dtoList = new ArrayList<>();
}
((List) dtoList).add(value);
}
propertyDescriptor.getWriteMethod().invoke(dto, dtoList);
} catch (IllegalAccessException | InvocationTargetException | IntrospectionException | IllegalArgumentException e) {
throw new ClientException(e.getMessage(), e);
}
}
use of com.nedap.archie.rm.support.identification.ObjectId in project ehrbase by ehrbase.
the class PersistedPartyIdentified method render.
@Override
public PartyProxy render(PartyIdentifiedRecord partyIdentifiedRecord) {
PartyRef partyRef = null;
if (partyIdentifiedRecord.getPartyRefType() != null) {
ObjectId objectID = new PersistedObjectId().fromDB(partyIdentifiedRecord);
partyRef = new PartyRef(objectID, partyIdentifiedRecord.getPartyRefNamespace(), partyIdentifiedRecord.getPartyRefType());
}
List<DvIdentifier> identifierList = new PartyIdentifiers(domainAccess).retrieve(partyIdentifiedRecord);
PartyIdentified partyIdentified = new PartyIdentified(partyRef, partyIdentifiedRecord.getName(), identifierList.isEmpty() ? null : identifierList);
return partyIdentified;
}
use of com.nedap.archie.rm.support.identification.ObjectId in project ehrbase by ehrbase.
the class ContextAccess method getPartyIdentifiedFromRecord.
private static PartyIdentified getPartyIdentifiedFromRecord(PartyIdentifiedRecord partyIdentifiedRecord, List<DvIdentifier> identifiers) {
PartyIdentified healthCareFacility;
PartyRef partyRef = null;
if (partyIdentifiedRecord.getPartyRefValue() != null && partyIdentifiedRecord.getPartyRefScheme() != null) {
ObjectId objectID = new PersistedObjectId().fromDB(partyIdentifiedRecord);
partyRef = new PartyRef(objectID, partyIdentifiedRecord.getPartyRefNamespace(), partyIdentifiedRecord.getPartyRefType());
}
healthCareFacility = new PartyIdentified(partyRef, partyIdentifiedRecord.getName(), identifiers.isEmpty() ? null : identifiers);
return healthCareFacility;
}
Aggregations