use of org.orcid.core.version.V2Convertible in project ORCID-Source by ORCID.
the class VersionConverterImplV2_0ToV2_1 method upgrade.
@Override
public V2Convertible upgrade(V2Convertible objectToUpgrade) {
Object objectToConvert = objectToUpgrade.getObjectToConvert();
Object targetObject = v2VersionObjectFactory.createEquivalentInstance(objectToConvert, UPPER_VERSION);
MappingContext context = new MappingContext.Factory().getContext();
context.setProperty("downgrade", false);
mapper.map(objectToConvert, targetObject, context);
return new V2Convertible(targetObject, UPPER_VERSION);
}
use of org.orcid.core.version.V2Convertible in project ORCID-Source by ORCID.
the class VersionConverterImplV2_0ToV2_1 method downgrade.
@Override
public V2Convertible downgrade(V2Convertible objectToDowngrade) {
Object objectToConvert = objectToDowngrade.getObjectToConvert();
Object targetObject = v2VersionObjectFactory.createEquivalentInstance(objectToConvert, LOWER_VERSION);
MappingContext context = new MappingContext.Factory().getContext();
context.setProperty("downgrade", true);
mapper.map(objectToConvert, targetObject, context);
return new V2Convertible(targetObject, LOWER_VERSION);
}
use of org.orcid.core.version.V2Convertible in project ORCID-Source by ORCID.
the class NotificationsApiServiceVersionedDelegatorImpl method downgradeResponse.
private Response downgradeResponse(Response response) {
Object entity = response.getEntity();
V2Convertible result = null;
if (entity != null) {
result = v2VersionConverterChain.downgrade(new V2Convertible(entity, MemberV2ApiServiceDelegator.LATEST_V2_VERSION), externalVersion);
}
return Response.fromResponse(response).entity(result.getObjectToConvert()).build();
}
use of org.orcid.core.version.V2Convertible in project ORCID-Source by ORCID.
the class MemberV2ApiServiceVersionedDelegatorImpl method upgradeResponse.
private Response upgradeResponse(Response response) {
Object entity = response.getEntity();
V2Convertible result = null;
if (entity != null) {
result = v2_1VersionConverterChain.upgrade(new V2Convertible(entity, MemberV2ApiServiceDelegator.LATEST_V2_VERSION), externalVersion);
return Response.fromResponse(response).entity(result.getObjectToConvert()).build();
}
return response;
}
use of org.orcid.core.version.V2Convertible in project ORCID-Source by ORCID.
the class ConvertVrc4ToV2Test method upgradePeerReviewsToVrc3Test.
@Test
public void upgradePeerReviewsToVrc3Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_v2.PeerReviews.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream rc3Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc4.xml");
InputStream rc4Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0.xml");
PeerReviews rc4PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(rc3Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
org.orcid.jaxb.model.record.summary_v2.PeerReviews rc4PeerReviews1 = (org.orcid.jaxb.model.record.summary_v2.PeerReviews) jaxbUnmarshaller.unmarshal(rc4Stream);
V2Convertible result = versionConverterV2_0_rc4ToV2_0.upgrade(new V2Convertible(rc4PeerReviews, "v2_rc4"));
org.orcid.jaxb.model.record.summary_v2.PeerReviews rc4PeerReviews2 = (org.orcid.jaxb.model.record.summary_v2.PeerReviews) result.getObjectToConvert();
assertEquals(rc4PeerReviews1, rc4PeerReviews2);
}
Aggregations