use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project goobi-workflow by intranda.
the class MetadataUtils method extractMetadataFromFile.
private static void extractMetadataFromFile(Path metsPath, RestProcess p, Map<String, Map<String, String>> labelMap, SearchRequest req) {
if (!Files.exists(metsPath)) {
return;
}
Document doc;
try (InputStream in = Files.newInputStream(metsPath)) {
doc = builder.build(in);
} catch (JDOMException | IOException e) {
log.error(e);
return;
}
for (Element el : authorityMetaXpath.evaluate(doc)) {
RestMetadata meta = new RestMetadata();
String name = el.getAttributeValue("name");
if (req.getWantedFields() != null && !req.getWantedFields().contains(name)) {
continue;
}
String type = el.getAttributeValue("type");
if ("person".equals(type)) {
meta.setValue(el.getChildText("displayName", goobiNamespace));
} else {
meta.setValue(el.getText());
}
meta.setAuthorityID(el.getChildText("authorityID", goobiNamespace));
meta.setAuthorityURI(el.getChildText("authorityURI", goobiNamespace));
meta.setAuthorityValue(el.getChildText("authorityValue", goobiNamespace));
meta.setLabels(labelMap.get(name));
p.addMetadata(name, meta);
}
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project goobi-workflow by intranda.
the class SRUClient method getResponseObject.
/**
* <p>
* Parse an XML String response and populate a response Object.
* </p>
*
* @param xmlData The XML String returned from the search
* @return SRUResponse An instantiated response object
*/
public SRUResponse getResponseObject(String xmlData) {
// Parsing
Document xmlResponse = parseXml(xmlData);
if (xmlResponse == null) {
log.error("Can't get results after XML parsing failed.");
return null;
}
// Processing
SRUResponse response = null;
try {
response = new SRUResponse(xmlResponse);
} catch (JDOMException ex) {
log.error("Error processing XML response:", ex);
}
return response;
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project webin-cli by enasequence.
the class ReadsXmlWriter method createRunXml.
String createRunXml(ReadsManifest manifest, String submissionTitle, String submissionAlias, String centerName, Path inputDir, Path uploadDir) {
try {
String title = submissionTitle;
Element runSetE = new Element("RUN_SET");
Element runE = new Element("RUN");
runSetE.addContent(runE);
Document doc = new Document(runSetE);
runE.setAttribute("alias", submissionAlias);
if (null != centerName && !centerName.isEmpty()) {
runE.setAttribute("center_name", centerName);
}
runE.addContent(new Element("TITLE").setText(title));
Element experimentRefE = new Element("EXPERIMENT_REF");
runE.addContent(experimentRefE);
experimentRefE.setAttribute("refname", submissionAlias);
Element dataBlockE = new Element("DATA_BLOCK");
runE.addContent(dataBlockE);
Element filesE = new Element("FILES");
dataBlockE.addContent(filesE);
manifest.files(FileType.BAM).stream().map(file -> file.getFile().toPath()).forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file, "bam", null)));
manifest.files(FileType.CRAM).stream().map(file -> file.getFile().toPath()).forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file, "cram", null)));
manifest.files(FileType.FASTQ).stream().forEach(file -> filesE.addContent(createFileElement(inputDir, uploadDir, file.getFile().toPath(), "fastq", file.getAttributes())));
Element runAttributesE = new Element("RUN_ATTRIBUTES");
if (manifest.getSubmissionTool() != null && !manifest.getSubmissionTool().isEmpty()) {
Element submissionToolRunAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL");
Element submissionToolRunAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionTool());
Element submissionToolRunAttributeE = new Element("RUN_ATTRIBUTE");
submissionToolRunAttributeE.addContent(submissionToolRunAttributeTagE);
submissionToolRunAttributeE.addContent(submissionToolRunAttributeValueE);
runAttributesE.addContent(submissionToolRunAttributeE);
}
if (manifest.getSubmissionToolVersion() != null && !manifest.getSubmissionToolVersion().isEmpty()) {
Element submissionToolVersionRunAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL_VERSION");
Element submissionToolVersionRunAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionToolVersion());
Element submissionToolVersionRunAttributeE = new Element("RUN_ATTRIBUTE");
submissionToolVersionRunAttributeE.addContent(submissionToolVersionRunAttributeTagE);
submissionToolVersionRunAttributeE.addContent(submissionToolVersionRunAttributeValueE);
runAttributesE.addContent(submissionToolVersionRunAttributeE);
}
if (runAttributesE.getContentSize() > 0) {
runE.addContent(runAttributesE);
}
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
StringWriter stringWriter = new StringWriter();
xmlOutput.output(doc, stringWriter);
return stringWriter.toString();
} catch (IOException ex) {
throw WebinCliException.systemError(ex);
}
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project webin-cli by enasequence.
the class ReadsXmlWriter method createExperimentXml.
private String createExperimentXml(ReadsManifest manifest, ReadsValidationResponse response, String submissionTitle, String submissionAlias, String centerName) {
String instrument = manifest.getInstrument();
String description = StringUtils.isBlank(manifest.getDescription()) ? "unspecified" : manifest.getDescription();
String libraryStrategy = manifest.getLibraryStrategy();
String librarySource = manifest.getLibrarySource();
String librarySelection = manifest.getLibrarySelection();
String libraryName = manifest.getLibraryName();
String platform = manifest.getPlatform();
Integer insertSize = manifest.getInsertSize();
try {
String title = submissionTitle;
Element experimentSetE = new Element("EXPERIMENT_SET");
Element experimentE = new Element("EXPERIMENT");
experimentSetE.addContent(experimentE);
Document doc = new Document(experimentSetE);
experimentE.setAttribute("alias", submissionAlias);
if (null != centerName && !centerName.isEmpty()) {
experimentE.setAttribute("center_name", centerName);
}
experimentE.addContent(new Element("TITLE").setText(title));
Element studyRefE = new Element("STUDY_REF");
experimentE.addContent(studyRefE);
if (manifest.getStudy() != null) {
studyRefE.setAttribute("accession", manifest.getStudy().getBioProjectId());
}
Element designE = new Element("DESIGN");
experimentE.addContent(designE);
Element designDescriptionE = new Element("DESIGN_DESCRIPTION");
designDescriptionE.setText(description);
designE.addContent(designDescriptionE);
Element sampleDescriptorE = new Element("SAMPLE_DESCRIPTOR");
if (manifest.getStudy() != null) {
sampleDescriptorE.setAttribute("accession", manifest.getSample().getBioSampleId());
}
designE.addContent(sampleDescriptorE);
Element libraryDescriptorE = new Element("LIBRARY_DESCRIPTOR");
designE.addContent(libraryDescriptorE);
if (null != libraryName) {
Element libraryNameE = new Element("LIBRARY_NAME");
libraryNameE.setText(libraryName);
libraryDescriptorE.addContent(libraryNameE);
}
Element libraryStrategyE = new Element("LIBRARY_STRATEGY");
libraryStrategyE.setText(libraryStrategy);
libraryDescriptorE.addContent(libraryStrategyE);
Element librarySourceE = new Element("LIBRARY_SOURCE");
librarySourceE.setText(librarySource);
libraryDescriptorE.addContent(librarySourceE);
Element librarySelectionE = new Element("LIBRARY_SELECTION");
librarySelectionE.setText(librarySelection);
libraryDescriptorE.addContent(librarySelectionE);
Element libraryLayoutE = new Element("LIBRARY_LAYOUT");
if (!response.isPaired()) {
libraryLayoutE.addContent(new Element("SINGLE"));
} else {
Element pairedE = new Element("PAIRED");
libraryLayoutE.addContent(pairedE);
if (null != insertSize) {
pairedE.setAttribute("NOMINAL_LENGTH", String.valueOf(insertSize));
}
}
libraryDescriptorE.addContent(libraryLayoutE);
Element platformE = new Element("PLATFORM");
experimentE.addContent(platformE);
Element platformRefE = new Element(platform);
platformE.addContent(platformRefE);
Element instrumentModelE = new Element("INSTRUMENT_MODEL");
instrumentModelE.setText(instrument);
platformRefE.addContent(instrumentModelE);
Element expAttributesE = new Element("EXPERIMENT_ATTRIBUTES");
if (manifest.getSubmissionTool() != null && !manifest.getSubmissionTool().isEmpty()) {
Element submissionToolExpAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL");
Element submissionToolExpAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionTool());
Element submissionToolExpAttributeE = new Element("EXPERIMENT_ATTRIBUTE");
submissionToolExpAttributeE.addContent(submissionToolExpAttributeTagE);
submissionToolExpAttributeE.addContent(submissionToolExpAttributeValueE);
expAttributesE.addContent(submissionToolExpAttributeE);
}
if (manifest.getSubmissionToolVersion() != null && !manifest.getSubmissionToolVersion().isEmpty()) {
Element submissionToolVersionExpAttributeTagE = new Element("TAG").setText("SUBMISSION_TOOL_VERSION");
Element submissionToolVersionExpAttributeValueE = new Element("VALUE").setText(manifest.getSubmissionToolVersion());
Element submissionToolVersionExpAttributeE = new Element("EXPERIMENT_ATTRIBUTE");
submissionToolVersionExpAttributeE.addContent(submissionToolVersionExpAttributeTagE);
submissionToolVersionExpAttributeE.addContent(submissionToolVersionExpAttributeValueE);
expAttributesE.addContent(submissionToolVersionExpAttributeE);
}
if (expAttributesE.getContentSize() > 0) {
experimentE.addContent(expAttributesE);
}
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
StringWriter stringWriter = new StringWriter();
xmlOutput.output(doc, stringWriter);
return stringWriter.toString();
} catch (IOException ex) {
throw WebinCliException.systemError(ex);
}
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project n2o-framework by i-novus-llc.
the class SelectiveUtil method readByPath.
@SuppressWarnings("unchecked")
public static <N> N readByPath(String uri, NamespaceReaderFactory readerFactory) {
try (InputStream inputStream = FileSystemUtil.getContentAsStream(uri)) {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(inputStream);
Element root = doc.getRootElement();
return (N) readerFactory.produce(root).read(root);
} catch (JDOMException | IOException e) {
throw new RuntimeException(e);
}
}
Aggregations