use of org.phenopackets.schema.v1.core.Resource in project biosamples-v4 by EBIBioSamples.
the class PhenopacketConversionHelper method getResource.
public Optional<Resource> getResource(PhenopacketAttribute attribute) {
Optional<Resource> optionalResource = Optional.empty();
if (attribute.getOntologyId() != null) {
String ontology = attribute.getOntologyId().split(":")[0];
OLSDataRetriever retriever = new OLSDataRetriever();
retriever.readResourceInfoFromUrl(ontology);
optionalResource = Optional.of(Resource.newBuilder().setId(retriever.getResourceId()).setName(retriever.getResourceName()).setUrl(retriever.getResourceUrl()).setNamespacePrefix(retriever.getResourcePrefix()).setVersion(retriever.getResourceVersion()).build());
}
return optionalResource;
}
use of org.phenopackets.schema.v1.core.Resource in project automatiko-engine by automatiko-io.
the class ResourceHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String id = attrs.getValue("id");
String name = attrs.getValue("name");
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
Map<String, Resource> resources = (Map<String, Resource>) buildData.getMetaData("Resources");
if (resources == null) {
resources = new HashMap<String, Resource>();
buildData.setMetaData("Resources", resources);
}
Resource resource = new Resource(id, name);
;
resources.put(id, resource);
return resource;
}
use of org.phenopackets.schema.v1.core.Resource in project automatiko-engine by automatiko-io.
the class UserTaskHandler method handleNode.
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
HumanTaskNode humanTaskNode = (HumanTaskNode) node;
Work work = humanTaskNode.getWork();
work.setName("Human Task");
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
Map<String, Resource> resources = (Map<String, Resource>) buildData.getMetaData("Resources");
Map<String, String> dataInputs = new HashMap<String, String>();
Map<String, String> dataOutputs = new HashMap<String, String>();
List<String> owners = new ArrayList<String>();
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
// ioSpec and data{Input,Output}Spec handled in super.handleNode(...)
if ("potentialOwner".equals(nodeName)) {
String owner = readPotentialOwner(xmlNode, humanTaskNode);
if (owner != null) {
owners.add(owner);
}
} else if ("performer".equals(nodeName)) {
org.w3c.dom.Node resourceNode = xmlNode.getFirstChild();
if (resourceNode != null) {
String resourceId = resourceNode.getTextContent();
if (resources.containsKey(resourceId)) {
owners.add(resources.get(resourceId).getName());
}
}
}
xmlNode = xmlNode.getNextSibling();
}
if (owners.size() > 0) {
String owner = owners.get(0);
for (int i = 1; i < owners.size(); i++) {
owner += "," + owners.get(i);
}
humanTaskNode.getWork().setParameter("ActorId", owner);
}
humanTaskNode.getWork().setParameter("NodeName", humanTaskNode.getName());
}
Aggregations