List of usage examples for org.dom4j Namespace Namespace
public Namespace(String prefix, String uri)
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())); }/*from w w w . ja v a 2 s. c om*/ 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 ww w .jav a 2 s. com*/ return result; }
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 w w . j a va2s . com*/ 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 ww . java 2 s. 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())); }/* ww w. j av 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 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()); }/*w ww. j a v a2s .c o m*/ 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 serializeNotificationToWrappedXML(Notification notification) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("notification"); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); root.add(new Namespace("a", EntityConstants.NAMESPACE_ENTITIES)); if (notification.getLaunchParameter() != null) { root.addElement("a:LaunchParameter").addText(notification.getLaunchParameter().toString()); }//from w w w .j ava2 s. c o m if (notification.getLocalizedMessages() != null) { Element n = root.addElement("a:LocalizedMessages"); n.add(new Namespace("b", EntityConstants.NAMESPACE_ARRAYS)); HashMap<String, String> messages = notification.getLocalizedMessages(); for (String lang : messages.keySet()) { Element messageKeyValuePair = n.addElement("b:KeyValueOfstringstring"); messageKeyValuePair.addElement("b:Key").addText(lang); messageKeyValuePair.addElement("b:Value").addText(messages.get(lang)); } } if (notification.getMessage() != null) { root.addElement("a:Message").addText(notification.getMessage()); } if (notification.getReciverPermission() != null) { root.addElement("a:ReciverPermission").addText(notification.getReciverPermission().toString()); } return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeUserIdsToWrappedXML(int[] receiverUserIds) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("receiverUserIds"); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); root.add(new Namespace("a", EntityConstants.NAMESPACE_ARRAYS)); for (int id : receiverUserIds) { Element idElement = root.addElement("a:int"); idElement.setText(Integer.toString(id)); }/*from w w w .j av a2 s. c o m*/ return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeListOfIntToWrappedXML(int[] ids) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("ArrayOfint"); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); root.add(new Namespace("a", EntityConstants.NAMESPACE_ARRAYS)); for (int id : ids) { Element idElement = root.addElement("a:int"); idElement.setText(Integer.toString(id)); }//from ww w . j ava 2s . c o m return root.asXML(); }