use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource in project muikku by otavanopisto.
the class DeusNexStructureParser method parseQueryDocument.
private Query parseQueryDocument(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
Element documentElement = (Element) DeusNexXmlUtils.findNodeByXPath(resourceElement, "styledocument");
List<Resource> embeddedElements = new ArrayList<>();
if (documentElement == null) {
logger.severe("Missing data/document node");
return null;
}
List<Element> embeddedResourceElements = DeusNexXmlUtils.getElementsByXPath(resourceElement, "embedded/res");
for (Element embeddedResourceElement : embeddedResourceElements) {
Resource resource = parseResource(embeddedResourceElement);
if (resource != null) {
embeddedElements.add(resource);
}
}
Query query = new Query();
parseBasicResourceProperties(resourceElement, query);
query.setDocument(documentElement);
query.setResources(embeddedElements);
query.setQueryIdType(DeusNexXmlUtils.getChildValue(resourceElement, "queryIdType"));
query.setQueryStorageType(DeusNexXmlUtils.getChildValue(resourceElement, "queryStorageType"));
query.setQueryState(DeusNexXmlUtils.getChildValue(resourceElement, "queryState"));
query.setQueryType(DeusNexXmlUtils.getChildValue(resourceElement, "queryType"));
return query;
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource in project muikku by otavanopisto.
the class DeusNexStructureParser method parseFCKQuery.
private Query parseFCKQuery(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
Element documentElement = (Element) DeusNexXmlUtils.findNodeByXPath(resourceElement, "document");
if (documentElement == null) {
logger.severe("Missing data/document node");
return null;
}
List<Resource> embeddedElements = new ArrayList<>();
List<Element> embeddedResourceElements = DeusNexXmlUtils.getElementsByXPath(resourceElement, "embedded/res");
for (Element embeddedResourceElement : embeddedResourceElements) {
Resource resource = parseResource(embeddedResourceElement);
if (resource != null) {
embeddedElements.add(resource);
}
}
Query query = new Query();
parseBasicResourceProperties(resourceElement, query);
query.setDocument(documentElement);
query.setResources(embeddedElements);
query.setQueryIdType(DeusNexXmlUtils.getChildValue(resourceElement, "queryIdType"));
query.setQueryStorageType(DeusNexXmlUtils.getChildValue(resourceElement, "queryStorageType"));
query.setQueryState(DeusNexXmlUtils.getChildValue(resourceElement, "queryState"));
query.setQueryType(DeusNexXmlUtils.getChildValue(resourceElement, "queryType"));
return query;
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource in project muikku by otavanopisto.
the class DeusNexDocumentImpl method mapParents.
private void mapParents(Resource resource) {
if (resource instanceof ResourceContainer) {
List<Resource> children = ((ResourceContainer) resource).getResources();
if (children != null) {
for (Resource child : children) {
parents.put(child.getNo(), resource.getNo());
mapParents(child);
}
}
}
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource in project muikku by otavanopisto.
the class DeusNexStructureParser method parseStyleDocument.
private Document parseStyleDocument(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
Element documentElement = (Element) DeusNexXmlUtils.findNodeByXPath(resourceElement, "document/styledocument");
if (documentElement == null) {
logger.severe("Missing data/document node");
return null;
}
List<Resource> embeddedElements = new ArrayList<>();
List<Element> embeddedResourceElements = DeusNexXmlUtils.getElementsByXPath(resourceElement, "embedded/res");
for (Element embeddedResourceElement : embeddedResourceElements) {
Resource resource = parseResource(embeddedResourceElement);
if (resource != null) {
embeddedElements.add(resource);
}
}
Document document = new Document();
parseBasicResourceProperties(resourceElement, document);
document.setDocument(documentElement);
document.setResources(embeddedElements);
return document;
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource in project muikku by otavanopisto.
the class DeusNexStructureParser method parseFolder.
private Folder parseFolder(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
List<Element> childResources = DeusNexXmlUtils.getElementsByXPath(resourceElement, "res");
List<Resource> resources = new ArrayList<>();
for (Element childResource : childResources) {
Resource resource = parseResource(childResource);
if (resource != null) {
resources.add(resource);
}
}
Folder folder = new Folder();
parseBasicResourceProperties(resourceElement, folder);
folder.setResources(resources);
return folder;
}
Aggregations