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
private List<CollaborationParticipant> deserializeXMLToListOfCollaborationParticipant(InputStream xmlStream) throws ParseException, DocumentException { List<CollaborationParticipant> result = new ArrayList<CollaborationParticipant>(); SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:ArrayOfCollaborationParticipant"; 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:CollaborationParticipant"); for (Node node : nodes) { CollaborationParticipant collaborationParticipant = new CollaborationParticipant(); Node n = node.selectSingleNode("loi:FirstName"); if (n.hasContent()) { collaborationParticipant.setFirstName(n.getStringValue()); }/*from w ww . j a va 2s. c o m*/ n = node.selectSingleNode("loi:LastName"); if (n.hasContent()) { collaborationParticipant.setFirstName(n.getStringValue()); } n = node.selectSingleNode("loi:CollaborationId"); if (n.hasContent()) { collaborationParticipant.setUserId(Integer.parseInt(n.getStringValue())); } n = node.selectSingleNode("loi:UserId"); if (n.hasContent()) { collaborationParticipant.setUserId(Integer.parseInt(n.getStringValue())); } result.add(collaborationParticipant); } return result; }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private LearningObjectiveReportSettings deserializeXMLToLearningObjectiveReportSettings(InputStream xmlStream) throws ParseException, DocumentException { LearningObjectiveReportSettings result = null; SAXReader reader = new SAXReader(); Document doc = reader.read(xmlStream); String lElem = "//loi:LearningObjectiveReportSettings"; doc.getRootElement().setQName(new QName(doc.getRootElement().getQName().getName(), new Namespace("loi", doc.getRootElement().getNamespaceURI()))); Element root = doc.getRootElement(); if (root.getName().equals("LearningObjectiveReportSettings")) { result = new LearningObjectiveReportSettings(); Node node = root.selectSingleNode(lElem + "/loi:AchievementLevelOrder"); if (node.hasContent()) { try { result.setAchievementLevelOrder(AchievementLevelOrder.valueOf(node.getStringValue())); } catch (IllegalArgumentException iea) { result.setAchievementLevelOrder(AchievementLevelOrder.HighestToLowest); }/* w w w.j a va 2s. c om*/ } node = root.selectSingleNode(lElem + "/loi:UseMastery"); if (node.hasContent()) { result.setUseMastery(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:LearningObjectiveMasteryRecurrenceType"); if (node.hasContent()) { try { result.setLearningObjectiveMasteryRecurrenceType( LearningObjectiveMasteryRecurrenceType.valueOf(node.getStringValue())); } catch (IllegalArgumentException iea) { result.setLearningObjectiveMasteryRecurrenceType(LearningObjectiveMasteryRecurrenceType.None); } } node = root.selectSingleNode(lElem + "/loi:Statuses"); if (node.hasContent()) { result.setStatuses(getLearningObjectiveAssessmentStatusesFromXml( node.selectNodes("loi:LearningObjectiveAssessmentStatus"))); } node = root.selectSingleNode(lElem + "/loi:ClientMasterySettings"); if (node.hasContent()) { result.setClientMasterySettings( getClientMasterySettingsHashMapFromXml(node.selectNodes("loi:MasterySettingsItem"))); } node = root.selectSingleNode(lElem + "/loi:ShowReportStatusForStudents"); if (node.hasContent()) { result.setShowReportStatusForStudents(Boolean.parseBoolean(node.getStringValue())); } node = root.selectSingleNode(lElem + "/loi:ConnectAssessmentCriteriaToScale"); if (node.hasContent()) { result.setConnectAssessmentCriteriaToScale(Boolean.parseBoolean(node.getStringValue())); } } return result; }
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())); }/*from w w w .j a va 2 s. com*/ 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 String serializeLearningObjectInstanceUserReportToXML(LearningObjectInstanceUserReport userReport) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("LearningObjectInstanceUserReport"); root.setQName(new QName("LearningObjectInstanceUserReport", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); fillLearningObjectInstanceUserReportXmlElement(root, userReport); return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceUserReportCommentOnCommentToXML( LearningObjectInstanceUserReportCommentOnComment reportComment) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("LearningObjectInstanceUserReportCommentOnComment"); root.setQName(new QName("LearningObjectInstanceUserReportCommentOnComment", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); if (reportComment.getUserId() != null) { root.addElement("UserId").addText(reportComment.getUserId().toString()); }// ww w . j ava 2 s. c om if (reportComment.getCommentText() != null) { root.addElement("CommentText").addText(reportComment.getCommentText()); } if (reportComment.getCommentSyncKey() != null) { root.addElement("CommentSyncKey").addText(reportComment.getCommentSyncKey()); } if (reportComment.getModifiedUtc() != null) { root.addElement("ModifiedUtc").addText(sdf.format(reportComment.getModifiedUtc())); } return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeNotificationToXML(Notification notification) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("Notification"); root.setQName(new QName("Notification", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); if (notification.getLaunchParameter() != null) { root.addElement("LaunchParameter").addText(notification.getLaunchParameter().toString()); }//from w w w . ja v a 2s . c om if (notification.getLocalizedMessages() != null) { Element n = root.addElement("LocalizedMessages"); n.add(new Namespace("a", EntityConstants.NAMESPACE_ARRAYS)); HashMap<String, String> messages = notification.getLocalizedMessages(); for (String lang : messages.keySet()) { Element messageKeyValuePair = n.addElement("a:KeyValueOfstringstring"); messageKeyValuePair.addElement("a:Key").addText(lang); messageKeyValuePair.addElement("a:Value").addText(messages.get(lang)); } } if (notification.getMessage() != null) { root.addElement("Message").addText(notification.getMessage()); } if (notification.getReciverPermission() != null) { root.addElement("ReciverPermission").addText(notification.getReciverPermission().toString()); } return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceUserReportsToXML( List<LearningObjectInstanceUserReport> userReports) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("ArrayOfLearningObjectInstanceUserReport"); root.setQName(new QName("ArrayOfLearningObjectInstanceUserReport", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); for (LearningObjectInstanceUserReport userReport : userReports) { Element n = root.addElement("LearningObjectInstanceUserReport"); fillLearningObjectInstanceUserReportXmlElement(n, userReport); }// www. j av a2 s . c om return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceToXML(LearningObjectInstance instance) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("LearningObjectInstance"); root.setQName(new QName("LearningObjectInstance", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); if (instance.getActiveFromUTC() != null) { String activeFromUTCText = sdf.format(instance.getActiveFromUTC()); root.addElement("ActiveFromUtc").addText(activeFromUTCText); }//from w ww . jav a2 s .com if (instance.getActiveToUTC() != null) { String activeToUTCText = sdf.format(instance.getActiveToUTC()); root.addElement("ActiveToUtc").addText(activeToUTCText); } root.addElement("AssessmentId").addText(instance.getAssessmentId().toString()); root.addElement("AssessmentStatusId").addText(instance.getAssessmentStatusId().toString()); root.addElement("IsAssessmentVisible").addText(String.valueOf(instance.getIsAssessmentVisible())); root.addElement("CreatedByUserId").addText("" + instance.getCreatedByUserId()); if (instance.getCreatedUTC() != null) { String createdUTCText = sdf.format(instance.getCreatedUTC()); root.addElement("CreatedUtc").addText(createdUTCText); } root.addElement("CourseCode").addText("" + instance.getCourseCode()); root.addElement("CourseId").addText("" + instance.getCourseId()); root.addElement("CourseSyncKey").addText("" + instance.getCourseSyncKey()); root.addElement("CourseOrganisationId").addText("" + instance.getCourseOrganisationId()); root.addElement("CourseOrganisationSyncKey").addText("" + instance.getCourseOrganisationSyncKey()); if (instance.getMaxScore() != null) { root.addElement("MaxScore").addText("" + instance.getMaxScore()); } if (instance.getDeadLineUTC() != null) { String deadlineUTCText = sdf.format(instance.getDeadLineUTC()); root.addElement("DeadlineUtc").addText(deadlineUTCText); } root.addElement("IsObligatory").addText(String.valueOf(instance.isIsObligatory())); root.addElement("LearningObjectId").addText("" + instance.getLearningObjectId()); root.addElement("LearningObjectInstanceId").addText("" + instance.getLearningObjectInstanceId()); if (instance.getModifiedUTC() != null) { String modifiedUTCText = sdf.format(instance.getModifiedUTC()); root.addElement("ModifiedUtc").addText(modifiedUTCText); } root.addElement("Title").addText(instance.getTitle()); return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectiveAssessmentsToXml( List<LearningObjectiveAssessment> learningObjectiveAssessments) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("ArrayOfLearningObjectiveAssessment"); root.setQName(new QName("ArrayOfLearningObjectiveAssessment", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); for (LearningObjectiveAssessment loAssessment : learningObjectiveAssessments) { Element n = root.addElement("LearningObjectiveAssessment"); n.addElement("LearningObjectiveId").addText(Integer.toString(loAssessment.getLearningObjectiveId())); n.addElement("UserId").addText(Integer.toString(loAssessment.getUserId())); n.addElement("RubricCriteriaItemId").addText(Integer.toString(loAssessment.getRubricCriteriaItemId())); n.addElement("PercentScore").addText(Double.toString(loAssessment.getPercentScore())); if (loAssessment.getComment() != null) { n.addElement("Comment").addText(loAssessment.getComment()); }//from w ww . j a v a 2s. c om n.addElement("Mastery").addText(Boolean.toString(loAssessment.getMastery())); n.addElement("Override").addText(Boolean.toString(loAssessment.getOverride())); if (loAssessment.getAssessedAchievementLevelId() != null) { n.addElement("AssessedAchievementLevelId") .addText(loAssessment.getAssessedAchievementLevelId().toString()); } n.addElement("Reportable").addText(Boolean.toString(loAssessment.getReportable())); } return root.asXML(); }
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 w w w . j av a2s . co m 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; }