List of usage examples for org.dom4j QName QName
public QName(String name, Namespace namespace)
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * xml looks like this// w w w . jav a 2s. c om <ArrayOfOrganizationRole xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <OrganizationRole> <HierarchyId>1</HierarchyId> <HomeOrganization>false</HomeOrganization> <Role>Administrator</Role> </OrganizationRole> <OrganizationRole> <HierarchyId>2</HierarchyId> <HomeOrganization>false</HomeOrganization> <Role>Administrator</Role> </OrganizationRole> <OrganizationRole> <HierarchyId>3</HierarchyId> <HomeOrganization>false</HomeOrganization> <Role>Administrator</Role> </OrganizationRole> <OrganizationRole> <HierarchyId>5</HierarchyId> <HomeOrganization>false</HomeOrganization> <Role>Administrator</Role> </OrganizationRole> <OrganizationRole> <HierarchyId>6</HierarchyId> <HomeOrganization>true</HomeOrganization> <Role>Administrator</Role> </OrganizationRole> </ArrayOfOrganizationRole> * * @param responseBodyAsStream * @return */ private List<OrganisationRole> deserializeXMLToOrganisationRoles(InputStream xmlStream) throws DocumentException { List<OrganisationRole> result = new ArrayList<OrganisationRole>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//org:ArrayOfOrganizationRole"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("org", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/org:OrganizationRole"); for (Node n : nodes) { OrganisationRole organisationRole = new OrganisationRole(); Node node = n.selectSingleNode("org:HierarchyId"); if (node.hasContent()) { organisationRole.setHierarchyId(Integer.parseInt(node.getStringValue())); } node = n.selectSingleNode("org:HomeOrganization"); if (node.hasContent()) { organisationRole.setHomeOrganization(Boolean.parseBoolean(node.getStringValue())); } node = n.selectSingleNode("org:Role"); if (node.hasContent()) { organisationRole.setRole(node.getStringValue()); } result.add(organisationRole); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<AppLicense> deserializeXMLToAppLicenses(InputStream xmlStream) throws DocumentException { List<AppLicense> result = new ArrayList<AppLicense>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfAppLicense"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:AppLicense"); for (Node n : nodes) { AppLicense appLicense = new AppLicense(); Node node = n.selectSingleNode("loi:LicenseId"); if (node.hasContent()) { appLicense.setLicenseId(Integer.parseInt(node.getStringValue())); }//from www . ja v a 2s .com node = n.selectSingleNode("loi:ExternalLicenseId"); if (node.hasContent()) { appLicense.setExternalLicenseId(node.getStringValue()); } result.add(appLicense); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private Site deserializeXMLToSite(InputStream xmlStream) throws ParseException, DocumentException { Site site = null;// w ww .j ava 2 s .c o m SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:Site"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); if (root.getName().equals("Site")) { site = new Site(); Node node = root.selectSingleNode(lElem + "/loi:Segment"); if (node.hasContent()) { try { site.setSegment(EducationSegment.valueOf(node.getStringValue())); } catch (IllegalArgumentException iea) { site.setSegment(EducationSegment.Other); } } node = root.selectSingleNode(lElem + "/loi:CountryCode"); if (node.hasContent()) { site.setCountryCode(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:Name"); if (node.hasContent()) { site.setName(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:ShortName"); if (node.hasContent()) { site.setShortName(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:BaseUrl"); if (node.hasContent()) { site.setBaseUrl(node.getStringValue()); } } return site; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private CustomerSettings deserializeXMLToCustomerSettings(InputStream xmlStream) throws ParseException, DocumentException { CustomerSettings customerSettings = null; SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:CustomerSettings"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); if (root.getName().equals("CustomerSettings")) { customerSettings = new CustomerSettings(); Node node = doc.selectSingleNode("loi:PlagiarismCode"); if (node.hasContent()) { customerSettings.setPlagiarismCode(node.getStringValue()); }//from w w w .j a va 2 s .c o m node = doc.selectSingleNode("loi:PlagiarismEmail"); if (node.hasContent()) { customerSettings.setPlagiarismEmail(node.getStringValue()); } node = doc.selectSingleNode("loi:PlagiarismShowStudentName"); if (node.hasContent()) { customerSettings.setPlagiarismShowStudentName(node.getStringValue()); } node = doc.selectSingleNode("loi:UsePlagiarism"); if (node.hasContent()) { customerSettings.setUsePlagiarism(Boolean.parseBoolean(node.getStringValue())); } } return customerSettings; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
/** * xml looks like this//from w w w . j a va 2 s . c o m <ArrayOfRubricCriteriaItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <RubricCriteriaItem> <Id>1</Id> <Title>First criteria item</Title> <LearningObjectiveId>33</LearningObjectiveId> <AchievementLevels> <RubricAchievementLevel> <Id>1</Id> <Text>Advanced</Text> <OrderNo>1</OrderNo> </RubricAchievementLevel> <RubricAchievementLevel> <Id>2</Id> <Text>Proficient</Text> <OrderNo>2</OrderNo> </RubricAchievementLevel> <RubricAchievementLevel> <Id>3</Id> <Text>Basic</Text> <OrderNo>4</OrderNo> </RubricAchievementLevel> <RubricAchievementLevel> <Id>4</Id> <Text>Below basic</Text> <OrderNo>4</OrderNo> </RubricAchievementLevel> </AchievementLevels> <UniqueId>12341234</UniqueId> </RubricCriteriaItem> </ArrayOfRubricCriteriaItem> * * @param responseBodyAsStream * @return */ private List<RubricCriteriaItem> deserializeXMLToCriteria(InputStream xmlStream) throws DocumentException { List<RubricCriteriaItem> result = new ArrayList<RubricCriteriaItem>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfRubricCriteriaItem"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:RubricCriteriaItem"); for (Node n : nodes) { RubricCriteriaItem rubric = new RubricCriteriaItem(); Node node = n.selectSingleNode("loi:Id"); if (node.hasContent()) { rubric.setId(Integer.parseInt(node.getStringValue())); } node = n.selectSingleNode("loi:Title"); if (node.hasContent()) { rubric.setTitle(node.getStringValue()); } node = n.selectSingleNode("loi:LearningObjectiveId"); if (node.hasContent()) { rubric.setLearningObjectiveId(Integer.parseInt(node.getStringValue())); } node = n.selectSingleNode("loi:AchievementLevels"); if (node.hasContent()) { rubric.setAchievementLevels( getRubricAchievementLevelsFromXml(n.selectNodes("loi:RubricAchievementLevel"))); } node = n.selectSingleNode("loi:UniqueId"); if (node.hasContent()) { rubric.setUniqueId(node.getStringValue()); } result.add(rubric); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<LearningObjective> deserializeXMLToListOfLearningObjectives(InputStream xmlStream) throws DocumentException { List<LearningObjective> result = new ArrayList<LearningObjective>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfLearningObjective"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:LearningObjective"); for (Node n : nodes) { LearningObjective lo = new LearningObjective(); Node node = n.selectSingleNode("loi:Id"); if (node.hasContent()) { lo.setId(Integer.parseInt(node.getStringValue())); }/* w ww . j a va 2s .co m*/ node = n.selectSingleNode("loi:Title"); if (node.hasContent()) { lo.setTitle(node.getStringValue()); } node = n.selectSingleNode("loi:Description"); if (node.hasContent()) { lo.setDescription(node.getStringValue()); } node = n.selectSingleNode("loi:Obsolete"); if (node.hasContent()) { lo.setObsolete(Boolean.parseBoolean(node.getStringValue())); } result.add(lo); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<LearningObjectInstanceUserReport> deserializeXMLToListOfLearningObjectInstanceUserReport( InputStream xmlStream) throws ParseException, DocumentException { List<LearningObjectInstanceUserReport> result = new ArrayList<LearningObjectInstanceUserReport>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfLearningObjectInstanceUserReport"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:LearningObjectInstanceUserReport"); for (Node n : nodes) { LearningObjectInstanceUserReport singleReport = new LearningObjectInstanceUserReport(); fillSingleLearningObjectInstanceUserReportEntityFromXml(singleReport, root, lElem, n); result.add(singleReport);//from w ww . j a v a 2 s . c o m } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<LearningObjectInstanceUser> deserializeXMLToListOfLearningObjectInstanceUser(InputStream xmlStream) throws ParseException, DocumentException { List<LearningObjectInstanceUser> result = new ArrayList<LearningObjectInstanceUser>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfLearningObjectInstanceUser"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:LearningObjectInstanceUser"); for (Node n : nodes) { LearningObjectInstanceUser singleUser = new LearningObjectInstanceUser(); fillSingleLearningObjectInstanceUserEntityFromXml(singleUser, root, lElem, n); result.add(singleUser);//w w w. j av a2 s . co m } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<AssessmentStatus> deserializeXMLToListOfPossibleAssessmentStatuses(InputStream xmlStream) throws ParseException, DocumentException { List<AssessmentStatus> result = new ArrayList<AssessmentStatus>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfAssessmentStatus"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); List<Node> nodes = root.selectNodes(lElem + "/loi:AssessmentStatus"); for (Node node : nodes) { AssessmentStatus assessmentStatus = new AssessmentStatus(); Node n = node.selectSingleNode("loi:AssessmentStatusId"); if (n.hasContent()) { assessmentStatus.setAssessmentStatusId(Integer.parseInt(n.getStringValue())); }/*w w w . j av a 2 s .c o m*/ n = node.selectSingleNode("loi:Title"); if (n.hasContent()) { assessmentStatus.setTitle(n.getStringValue()); } result.add(assessmentStatus); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private LearningObjectInstanceUserReport deserializeXMLToLearningObjectInstanceUserReport(InputStream xmlStream) throws ParseException, DocumentException { LearningObjectInstanceUserReport result = new LearningObjectInstanceUserReport(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:LearningObjectInstanceUserReport"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); if (root.getName().equals("LearningObjectInstanceUserReport")) { result = new LearningObjectInstanceUserReport(); fillSingleLearningObjectInstanceUserReportEntityFromXml(result, root, lElem, root); }//from w w w .jav a 2 s . c o m return result; }