List of usage examples for org.dom4j Node hasContent
boolean hasContent();
hasContent
returns true if this node is a Branch (either an Element or a Document) and it contains at least one content node such as a child Element or Text node.
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private LearningObjectiveMasteryClientSettings getClientMasterySettingsFromXml(Node n) { LearningObjectiveMasteryClientSettings masterySettings = new LearningObjectiveMasteryClientSettings(); Node node = n.selectSingleNode("loi:AffectsByLevel"); if (node.hasContent()) { masterySettings.setAffectsByLevel(Boolean.parseBoolean(node.getStringValue())); }//from www .j a v a 2 s.c o m node = n.selectSingleNode("loi:AffectsByResettingMastery"); if (node.hasContent()) { masterySettings.setAffectsByResettingMastery(Boolean.parseBoolean(node.getStringValue())); } node = n.selectSingleNode("loi:MasteredWithoutOverride"); if (node.hasContent()) { masterySettings.setMasteredWithoutOverride(Boolean.parseBoolean(node.getStringValue())); } node = n.selectSingleNode("loi:BreaksRecurrence"); if (node.hasContent()) { masterySettings.setBreaksRecurrence(Boolean.parseBoolean(node.getStringValue())); } node = n.selectSingleNode("loi:IsReportMastered"); if (node.hasContent()) { masterySettings.setIsReportMastered(Boolean.parseBoolean(node.getStringValue())); } return masterySettings; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<LearningObjectiveAssessment> deserializeXMLToListOfLearningObjectiveAssessment( InputStream xmlStream) throws ParseException, DocumentException { List<LearningObjectiveAssessment> result = new ArrayList<LearningObjectiveAssessment>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfLearningObjectiveAssessment"; 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:LearningObjectiveAssessment"); for (Node node : nodes) { LearningObjectiveAssessment learningObjectiveAssessment = new LearningObjectiveAssessment(); Node n = node.selectSingleNode("loi:LearningObjectiveId"); if (n.hasContent()) { learningObjectiveAssessment.setLearningObjectiveId(Integer.parseInt(n.getStringValue())); }/*w w w.j a v a2s . c o m*/ n = node.selectSingleNode("loi:UserId"); if (n.hasContent()) { learningObjectiveAssessment.setUserId(Integer.parseInt(n.getStringValue())); } n = node.selectSingleNode("loi:RubricCriteriaItemId"); if (n.hasContent()) { learningObjectiveAssessment.setRubricCriteriaItemId(Integer.parseInt(n.getStringValue())); } n = node.selectSingleNode("loi:PercentScore"); if (n.hasContent()) { learningObjectiveAssessment.setPercentScore(Double.parseDouble(n.getStringValue())); } n = node.selectSingleNode("loi:Comment"); if (n.hasContent()) { learningObjectiveAssessment.setComment(n.getStringValue()); } n = node.selectSingleNode("loi:Mastery"); if (n.hasContent()) { learningObjectiveAssessment.setMastery(Boolean.parseBoolean(n.getStringValue())); } n = node.selectSingleNode("loi:Override"); if (n.hasContent()) { learningObjectiveAssessment.setOverride(Boolean.parseBoolean(n.getStringValue())); } n = node.selectSingleNode("loi:AssessedAchievementLevelId"); if (n.hasContent()) { learningObjectiveAssessment.setAssessedAchievementLevelId(Integer.parseInt(n.getStringValue())); } n = node.selectSingleNode("loi:Reportable"); if (n.hasContent()) { learningObjectiveAssessment.setReportable(Boolean.parseBoolean(n.getStringValue())); } result.add(learningObjectiveAssessment); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<AssessmentItem> deserializeXMLToListOfAssessmentItems(InputStream xmlStream) throws ParseException, DocumentException { List<AssessmentItem> result = new ArrayList<AssessmentItem>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfAssessmentItem"; 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:AssessmentItem"); for (Node node : nodes) { AssessmentItem assessmentItem = new AssessmentItem(); Node n = node.selectSingleNode("loi:AssessmentId"); if (n.hasContent()) { assessmentItem.setAssessmentId(Integer.parseInt(n.getStringValue())); }/*from ww w . j ava 2 s . com*/ n = node.selectSingleNode("loi:AssessmentItemId"); if (n.hasContent()) { assessmentItem.setAssessmentItemId(Integer.parseInt(n.getStringValue())); } n = node.selectSingleNode("loi:Description"); if (n.hasContent()) { assessmentItem.setDescription(n.getStringValue()); } n = node.selectSingleNode("loi:PercentFromAndIncl"); if (n.hasContent()) { assessmentItem.setPercentFromAndIncl(Double.parseDouble(n.getStringValue())); } n = node.selectSingleNode("loi:PercentTo"); if (n.hasContent()) { assessmentItem.setPercentTo(Double.parseDouble(n.getStringValue())); } n = node.selectSingleNode("loi:Title"); if (n.hasContent()) { assessmentItem.setTitle(n.getStringValue()); } result.add(assessmentItem); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private List<Assessment> deserializeXMLToListOfAssessments(InputStream xmlStream) throws ParseException, DocumentException { List<Assessment> result = new ArrayList<Assessment>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfAssessment"; 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:Assessment"); for (Node node : nodes) { Assessment assessment = new Assessment(); Node n = node.selectSingleNode("loi:AssessmentId"); if (n.hasContent()) { assessment.setAssessmentId(Integer.parseInt(n.getStringValue())); }//from w w w.j av a 2s .c o m n = node.selectSingleNode("loi:Description"); if (n.hasContent()) { assessment.setDescription(n.getStringValue()); } n = node.selectSingleNode("loi:Title"); if (n.hasContent()) { assessment.setTitle(n.getStringValue()); } result.add(assessment); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private LearningObjectInstance deserializeXMLToLearningObjectInstance(InputStream xmlStream) throws ParseException, DocumentException { LearningObjectInstance loi = null;//from w w w.j a va2s . c o m SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:LearningObjectInstance"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); if (root.getName().equals("LearningObjectInstance")) { loi = new LearningObjectInstance(); Node node = root.selectSingleNode(lElem + "/loi:ActiveToUtc"); if (node != null && node.hasContent()) { loi.setActiveToUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:DeadlineUtc"); if (node != null && node.hasContent()) { loi.setDeadLineUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:ActiveFromUtc"); if (node != null && node.hasContent()) { loi.setActiveFromUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:CreatedUtc"); if (node != null && node.hasContent()) { loi.setCreatedUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:ModifiedUtc"); if (node != null && node.hasContent()) { loi.setModifiedUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:Title"); if (node != null && node.hasContent()) { loi.setTitle(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:LearningObjectInstanceId"); if (node != null && node.hasContent()) { loi.setLearningObjectInstanceId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:LearningObjectId"); if (node != null && node.hasContent()) { loi.setLearningObjectId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:ModifiedUtc"); if (node != null && node.hasContent()) { loi.setModifiedUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:CreatedUtc"); if (node != null && node.hasContent()) { loi.setCreatedUTC(sdf.parse(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:CreatedByUserId"); if (node != null && node.hasContent()) { loi.setCreatedByUserId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:IsObligatory"); if (node != null && node.hasContent()) { loi.setIsObligatory(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:AssessmentId"); if (node != null && node.hasContent()) { loi.setAssessmentId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:AssessmentStatusId"); if (node != null && node.hasContent()) { loi.setAssessmentStatusId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:IsAssessmentVisible"); if (node != null && node.hasContent()) { loi.setIsAssessmentVisible(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:CourseCode"); if (node != null && node.hasContent()) { loi.setCourseCode(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:CourseId"); if (node != null && node.hasContent()) { loi.setCourseId(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:CourseSyncKey"); if (node != null && node.hasContent()) { loi.setCourseSyncKey(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:CourseOrganisationId"); if (node != null && node.hasContent()) { loi.setCourseOrganisationId(Integer.parseInt(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:CourseOrganisationSyncKey"); if (node != null && node.hasContent()) { loi.setCourseOrganisationSyncKey(node.getStringValue()); } node = root.selectSingleNode(lElem + "/loi:MaxScore"); if (node != null && node.hasContent()) { loi.setMaxScore(Double.parseDouble(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:SubmissionType"); if (node != null && node.hasContent()) { try { loi.setSubmissionType(SubmissionType.valueOf(node.getStringValue())); } catch (IllegalArgumentException iea) { loi.setSubmissionType(SubmissionType.NotInUse); } } node = root.selectSingleNode(lElem + "/loi:UsePlagiarism"); if (node != null && node.hasContent()) { loi.setUsePlagiarism(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:UseAnonymousSubmission"); if (node != null && node.hasContent()) { loi.setUseAnonymousSubmission(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:HasLearningObjectiveAssessmentCriteria"); if (node != null && node.hasContent()) { loi.setHasLearningObjectiveAssessmentCriteria(Boolean.parseBoolean(node.getStringValue())); } } return loi; }