use of oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest in project nhin-d by DirectProject.
the class DefaultXdmXdsTransformerTest method testGetDocId_SubmitObjectsRequest.
/**
* Test the getDocId(SubmitObjectsRequest) method.
*/
public void testGetDocId_SubmitObjectsRequest() {
DefaultXdmXdsTransformer transformer = new DefaultXdmXdsTransformer();
QName qname = null;
String output = null;
SubmitObjectsRequest input = null;
ExternalIdentifierType eit = null;
RegistryObjectListType registryObject = null;
RegistryPackageType registryPackageType = null;
ExtrinsicObjectType extrinsicObjectType = null;
List<ExternalIdentifierType> externalIdentifiers = null;
JAXBElement<ExtrinsicObjectType> jaxbExtrinsicObject = null;
JAXBElement<RegistryPackageType> jaxbRegistryPackageTypeObject = null;
List<JAXBElement<? extends IdentifiableType>> identifiableList = null;
registryObject = new RegistryObjectListType();
identifiableList = registryObject.getIdentifiable();
eit = new ExternalIdentifierType();
eit.setIdentificationScheme("urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab");
eit.setValue("eitValue");
extrinsicObjectType = new ExtrinsicObjectType();
externalIdentifiers = extrinsicObjectType.getExternalIdentifier();
externalIdentifiers.add(eit);
qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", "ExtrinsicObject");
jaxbExtrinsicObject = new JAXBElement<ExtrinsicObjectType>(qname, ExtrinsicObjectType.class, extrinsicObjectType);
registryPackageType = new RegistryPackageType();
qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", "RegistryPackage");
jaxbRegistryPackageTypeObject = new JAXBElement<RegistryPackageType>(qname, RegistryPackageType.class, registryPackageType);
identifiableList.add(jaxbRegistryPackageTypeObject);
identifiableList.add(jaxbExtrinsicObject);
input = new SubmitObjectsRequest();
input.setRegistryObjectList(registryObject);
output = transformer.getDocId(input);
assertEquals("Output does not match expected", "eitValue", output);
registryObject = new RegistryObjectListType();
input = new SubmitObjectsRequest();
input.setRegistryObjectList(registryObject);
output = transformer.getDocId(input);
assertEquals("Output does not match expected", null, output);
}
use of oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest in project nhin-d by DirectProject.
the class DefaultXdmXdsTransformer method getDocName.
public String getDocName(File file) throws TransformationException {
LOGGER.trace("Begin transformation of XDM to XDS (file)");
ZipFile zipFile = null;
String objectId = null;
ProvideAndRegisterDocumentSetRequestType prsr = new ProvideAndRegisterDocumentSetRequestType();
try {
zipFile = new ZipFile(file, ZipFile.OPEN_READ);
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
ZipEntry zipEntry = null;
// load the ZIP archive into memory
while (zipEntries.hasMoreElements()) {
zipEntry = zipEntries.nextElement();
String zname = zipEntry.getName();
LOGGER.trace("Processing a ZipEntry " + zname);
if (!zipEntry.isDirectory()) {
String subsetDirspec = getSubmissionSetDirspec(zipEntry.getName());
// Read metadata
if (matchName(zname, subsetDirspec, XDM_FILENAME_METADATA)) {
ByteArrayOutputStream byteArrayOutputStream = readData(zipFile, zipEntry);
SubmitObjectsRequest submitObjectRequest = (SubmitObjectsRequest) XmlUtils.unmarshal(byteArrayOutputStream.toString(), oasis.names.tc.ebxml_regrep.xsd.lcm._3.ObjectFactory.class);
prsr.setSubmitObjectsRequest(submitObjectRequest);
objectId = getDocName(submitObjectRequest);
}
// Read data
}
}
zipFile.close();
} catch (Exception e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("Unable to complete getObjectId.", e);
}
throw new TransformationException("Unable to complete getObjectId.", e);
}
return objectId;
}
use of oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest in project nhin-d by DirectProject.
the class DefaultXdmXdsTransformer method getDocName.
protected String getDocName(SubmitObjectsRequest submitObjectRequest) {
if (submitObjectRequest == null) {
throw new IllegalArgumentException("SubmitObjectRequest must not be null.");
}
String ret = null;
RegistryObjectListType rol = submitObjectRequest.getRegistryObjectList();
List<JAXBElement<? extends IdentifiableType>> extensible = rol.getIdentifiable();
for (JAXBElement<? extends IdentifiableType> elem : extensible) {
String type = elem.getDeclaredType().getName();
Object value = elem.getValue();
if (StringUtils.equals(type, "oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType")) {
String obId = ((ExtrinsicObjectType) value).getId();
String mimeType = ((ExtrinsicObjectType) value).getMimeType();
String suffix = "xml";
if (mimeType.indexOf("xml") >= 0) {
suffix = "xml";
} else if (mimeType.indexOf("pdf") >= 0) {
suffix = "pdf";
}
ret = obId + "." + suffix;
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(type + " " + value.toString());
}
}
}
return ret;
}
Aggregations