List of usage examples for org.dom4j Element elementText
String elementText(QName qname);
From source file:org.talend.designer.alfrescooutput.data.MetadataManager.java
License:Open Source License
/** * Fills the given maps with the typing metadatas found in the given alfresco metamodel element. * NB. avoids system metadata : base and referenceable, * noderef pseudo prop (equivalent for sys:referenceable props) must be handled elsewhere. * @param alfrescoModelElement//from w ww.j a v a 2 s. co m * @param metadataMap * @param missingTypeNames * @param missingAspectNames */ protected void fillMetadatas(Element alfrescoModelElement, List<String> missingTypeNames, List<String> missingAspectNames) { String parentName = alfrescoModelElement.elementText("parent"); //$NON-NLS-1$ if (parentName != null && !parentName.equals("sys:base")) { // avoiding system metadata : base and referenceable //$NON-NLS-1$ boolean isType = "type".equals(alfrescoModelElement.getName()); //$NON-NLS-1$ Element parent = ((isType) ? modelManager.getAvailableTypes() : modelManager.getAvailableAspects()) .getAlfrescoModelElementMap().get(parentName); if (parent != null) { this.fillMetadatas(parent, missingTypeNames, missingAspectNames); } else { // TODO not if sys:base ? ((isType) ? missingTypeNames : missingAspectNames).add(parentName); } } Element mandatoryAspectsElt = alfrescoModelElement.element("mandatory-aspects"); //$NON-NLS-1$ if (mandatoryAspectsElt != null) { for (Element aspectElt : (List<Element>) mandatoryAspectsElt.elements("aspect")) { //$NON-NLS-1$ String aspectName = aspectElt.getText(); Element aspect = modelManager.getAvailableAspects().getAlfrescoModelElementMap().get(aspectName); if (aspect != null) { this.fillMetadatas(aspect, missingTypeNames, missingAspectNames); } else { missingAspectNames.add(aspectName); } } } // properties : Element propertiesElt = alfrescoModelElement.element("properties"); //$NON-NLS-1$ if (propertiesElt != null) { for (Element property : (List<Element>) propertiesElt.elements()) { if (!"true".equals(property.elementText("protected"))) { //$NON-NLS-1$ //$NON-NLS-2$ propertyMap.put(property.attributeValue("name"), property); //$NON-NLS-1$ } // else filtering out protected } } // associations and child-associations : Element associationsElt = alfrescoModelElement.element("associations"); //$NON-NLS-1$ if (associationsElt != null) { for (Element association : (List<Element>) associationsElt.elements()) { associationMap.put(association.attributeValue("name"), association); //$NON-NLS-1$ } } // NB. child-associations can only be set to target an existing element. // to create a new element with a target association, targetLocation must be used. }
From source file:org.talend.designer.alfrescooutput.ui.AlfrescoModelLabelProvider.java
License:Open Source License
public String getText(Object element) { if (element == null) { return ""; //$NON-NLS-1$ }/*ww w. j a v a 2s .c o m*/ Element alfrescoModelElement = (Element) element; return alfrescoModelElement.elementText("title") + " (" //$NON-NLS-1$ //$NON-NLS-2$ + alfrescoModelElement.attributeValue("name") + ")"; //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:org.talend.designer.alfrescooutput.ui.AlfrescoModelTableLabelProvider.java
License:Open Source License
public String getColumnText(Object element, int columnIndex) { if (element == null) { return ""; //$NON-NLS-1$ }//www .j a v a 2 s .co m Element alfrescoModelElement = (Element) element; switch (columnIndex) { case 0: return alfrescoModelElement.elementText("title"); //$NON-NLS-1$ case 1: return alfrescoModelElement.attributeValue("name"); //$NON-NLS-1$ default: return ""; //$NON-NLS-1$ } }
From source file:org.unitime.timetable.solver.ui.AssignmentPreferenceInfo.java
License:Open Source License
public void load(Element root) throws Exception { int version = Integer.parseInt(root.attributeValue("version")); if (version == sVersion) { iNormalizedTimePreference = Double.parseDouble(root.elementText("normTimePref")); iBestNormalizedTimePreference = Double.parseDouble(root.elementText("bestNormTimePref")); iTimePreference = Integer.parseInt(root.elementText("timePref")); for (Iterator i = root.elementIterator("roomPref"); i.hasNext();) { Element e = (Element) i.next(); iRoomPreference.put(Long.valueOf(e.attributeValue("id")), Integer.valueOf(e.getText())); }//from ww w . j ava 2s. c o m iBestRoomPreference = Integer.parseInt(root.elementText("bestRoomPref")); iNrStudentConflicts = Integer.parseInt(root.elementText("nrStudentConf")); iNrHardStudentConflicts = Integer.parseInt(root.elementText("nrHardStudentConf")); iNrDistanceStudentConflicts = Integer.parseInt(root.elementText("nrDistanceStudentConf")); iNrCommitedStudentConflicts = Integer.parseInt(root.elementText("nrCommitedStudentConf")); iNrTimeLocations = Integer.parseInt(root.elementText("nrTimeLoc")); iNrRoomLocations = Integer.parseInt(root.elementText("nrRoomLoc")); iNrSameRoomPlacementsNoConf = Integer.parseInt(root.elementText("nrSameRoomPlacNoConf")); iNrSameTimePlacementsNoConf = Integer.parseInt(root.elementText("nrSameTimePlacNoConf")); iNrPlacementsNoConf = Integer.parseInt(root.elementText("nrPlacNoConf")); iBtbInstructorPreference = Integer.parseInt(root.elementText("btbInstrPref")); iIsInitial = Boolean.valueOf(root.elementText("isInitial")).booleanValue(); iInitialAssignment = root.elementText("iniAssign"); iHasInitialSameTime = Boolean.valueOf(root.elementText("hasIniSameTime")).booleanValue(); iHasInitialSameRoom = Boolean.valueOf(root.elementText("hasIniSameRoom")).booleanValue(); iPerturbationPenalty = Double.parseDouble(root.elementText("pertPenalty")); iTooBigRoomPreference = Integer.parseInt(root.elementText("tooBig")); iMinRoomSize = Long.parseLong(root.elementText("minSize")); iUselessHalfHours = Integer.parseInt(root.elementText("uselessHalfHours")); iDeptBalancPenalty = Double.parseDouble(root.elementText("deptBalanc")); iGroupConstraintPref = Integer.parseInt(root.elementText("groupConstr")); if (root.elementText("spread") != null) iSpreadPenalty = Double.parseDouble(root.elementText("spread")); if (root.elementText("maxSpread") != null) iMaxSpreadPenalty = Double.parseDouble(root.elementText("maxSpread")); else iMaxSpreadPenalty = iSpreadPenalty; if (root.elementText("maxDeptBalanc") != null) iMaxDeptBalancPenalty = Integer.parseInt(root.elementText("maxDeptBalanc")); else iMaxDeptBalancPenalty = (int) iDeptBalancPenalty; if (root.elementText("datePref") != null) iDatePatternPref = Integer.parseInt(root.elementText("datePref")); } }
From source file:org.unitime.timetable.solver.ui.BtbInstructorConstraintInfo.java
License:Open Source License
public void load(Element root) throws Exception { int version = Integer.parseInt(root.attributeValue("version")); if (version == sVersion) { iInstructorId = Long.valueOf(root.elementText("instructor")); iPreference = Integer.parseInt(root.elementText("pref")); }/*from w w w . j a v a2s . c o m*/ }
From source file:org.unitime.timetable.solver.ui.GroupConstraintInfo.java
License:Open Source License
public void load(Element root) throws Exception { int version = Integer.parseInt(root.attributeValue("version")); if (version == 1) { if (root.element("name") != null) iName = root.element("name").getText(); iPreference = root.element("pref").getText(); iIsSatisfied = Boolean.valueOf(root.element("isSatisfied").getText()).booleanValue(); iType = root.elementText("type"); }//w w w.j av a2 s . co m }
From source file:org.unitime.timetable.solver.ui.JenrlInfo.java
License:Open Source License
public void load(Element root) throws Exception { int version = Integer.parseInt(root.attributeValue("version")); if (version == 1) { iJenrl = Double.parseDouble(root.elementText("jenrl")); iIsSatisfied = Boolean.valueOf(root.elementText("satisfied")).booleanValue(); iIsDistance = Boolean.valueOf(root.elementText("dist")).booleanValue(); iIsFixed = Boolean.valueOf(root.elementText("fixed")).booleanValue(); iIsHard = Boolean.valueOf(root.elementText("hard")).booleanValue(); if (root.elementText("distance") != null) iDistance = Double.parseDouble(root.elementText("distance")); if (root.elementText("commited") == null) { iIsCommited = false;//from w ww . ja v a 2 s . co m } else { iIsCommited = Boolean.valueOf(root.elementText("commited")).booleanValue(); } if (root.elementText("important") == null) { iIsImportant = false; } else { iIsImportant = Boolean.valueOf(root.elementText("important")).booleanValue(); } if (root.elementText("instructor") == null) { iIsInstructor = false; } else { iIsInstructor = Boolean.valueOf(root.elementText("instructor")).booleanValue(); } } }
From source file:org.vosao.business.impl.imex.FolderExporterImpl.java
License:Open Source License
private void readFolder(Element element, final FolderEntity parent) throws DaoTaskException { String name = element.elementText("name"); String title = element.elementText("title"); FolderEntity folder;// w ww .jav a2 s.c o m if (name.equals("/") && parent.isRoot()) { folder = getDao().getFolderDao().getByPath("/"); } else { folder = getDao().getFolderDao().getByParentName(parent.getId(), name); if (folder == null) { folder = new FolderEntity(title, name, parent.getId()); } } folder.setTitle(title); getDaoTaskAdapter().folderSave(folder); readFolderPermissions(element.element("permissions"), folder); for (Iterator<Element> i = element.elementIterator(); i.hasNext();) { Element e = i.next(); if (e.getName().equals("folder")) { readFolder(e, folder); } } }
From source file:org.vosao.business.impl.imex.FolderExporterImpl.java
License:Open Source License
private void readFolderPermissions(Element permissionsElement, final FolderEntity folder) { for (Iterator<Element> i = permissionsElement.elementIterator(); i.hasNext();) { Element element = i.next(); if (element.getName().equals("permission")) { String groupName = element.elementText("group"); GroupEntity group = getDao().getGroupDao().getByName(groupName); if (group == null) { logger.error("Group " + groupName + " was not found."); continue; }//from w w w . jav a 2 s. c o m FolderPermissionType permType = FolderPermissionType.valueOf(element.elementText("permissionType")); getBusiness().getFolderPermissionBusiness().setPermission(folder, group, permType); } } }
From source file:org.vosao.business.impl.imex.GroupExporterImpl.java
License:Open Source License
public void readGroups(Element groupsElement) throws DaoTaskException { Map<Long, UserEntity> usersMap = UserHelper.createIdMap(getDao().getUserDao().select()); for (Iterator<Element> i = groupsElement.elementIterator(); i.hasNext();) { Element element = i.next(); if (element.getName().equals("group")) { String name = element.elementText("name"); GroupEntity group = getDao().getGroupDao().getByName(name); if (group == null) { group = new GroupEntity(name); } else { group.setName(name);/*from ww w . j a v a2s.c o m*/ } getDaoTaskAdapter().groupSave(group); for (Iterator<Element> j = element.element("users").elementIterator(); j.hasNext();) { Element userElement = j.next(); UserEntity user = getDao().getUserDao().getByEmail(userElement.getText()); if (user != null) { UserGroupEntity userGroup = getDao().getUserGroupDao().getByUserGroup(group.getId(), user.getId()); if (userGroup == null) { userGroup = new UserGroupEntity(group.getId(), user.getId()); } getDaoTaskAdapter().userGroupSave(userGroup); } } } } }