List of usage examples for org.dom4j DocumentHelper createElement
public static Element createElement(String name)
From source file:cz.fi.muni.xkremser.editor.server.newObject.FoxmlBuilder.java
License:Open Source License
protected void decorateDCStream() { Element rootElement = DocumentHelper.createElement(new QName("dc", Namespaces.oai_dc)); rootElement.add(Namespaces.dc);/*www. j ava2 s.c om*/ rootElement.add(Namespaces.xsi); Element title = rootElement.addElement(new QName("title", Namespaces.dc)); title.addText(getLabel()); Element identifier = rootElement.addElement(new QName("identifier", Namespaces.dc)); identifier.setText(getPid()); Element type = rootElement.addElement(new QName("type", Namespaces.dc)); type.addText("model:" + getModel().getValue()); Element rights = rootElement.addElement(new QName("rights", Namespaces.dc)); rights.addText("policy:" + getPolicy().toString().toLowerCase()); appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.DC, rootElement, null, null); dcXmlContent = rootElement.getDocument(); }
From source file:cz.mzk.editor.server.fedora.utils.FoxmlUtils.java
License:Open Source License
public static org.dom4j.Element createModsCollectionEl() { org.dom4j.Element modsCollection = DocumentHelper .createElement(new QName("modsCollection", Namespaces.mods)); modsCollection.add(Namespaces.mods); String modsSchema = "https://raw.github.com/moravianlibrary/MEditor/master/resources/xml/mods-3-3.xsd";//"http://www.loc.gov/standards/mods/v3/mods-3-3.xsd"; modsCollection.addAttribute("schemaLocation", Namespaces.mods.getURI() + " " + modsSchema); return modsCollection; }
From source file:cz.mzk.editor.server.newObject.FoxmlBuilder.java
License:Open Source License
protected void decorateDCStream() { Element rootElement = DocumentHelper.createElement(new QName("dc", Namespaces.oai_dc)); rootElement.add(Namespaces.dc);//from w ww. jav a2 s . c o m rootElement.add(Namespaces.xsi); Element title = rootElement.addElement(new QName("title", Namespaces.dc)); title.addText(getLabel()); Element identifier = rootElement.addElement(new QName("identifier", Namespaces.dc)); identifier.setText(getPid()); Element type = rootElement.addElement(new QName("type", Namespaces.dc)); type.addText("model:" + getModel().getValue().substring(0, 1) + getModel().getValue().substring(1).toLowerCase()); Element rights = rootElement.addElement(new QName("rights", Namespaces.dc)); rights.addText("policy:" + getPolicy().toString().toLowerCase()); appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.DC, rootElement, null, null); dcXmlContent = rootElement.getDocument(); }
From source file:de.tu_berlin.cit.intercloud.xmpp.core.resultsetmanagement.ResultSet.java
License:Open Source License
/** * Generates a Result Set Management 'set' element that describes the parto * of the result set that was generated. You typically would use the List * that was returned by {@link #applyRSMDirectives(Element)} as an argument * to this method./*from w ww. j ava2 s .co m*/ * * @param returnedResults * The subset of Results that is returned by the current query. * @return An Element named 'set' that can be included in the result IQ * stanza, which returns the subset of results. */ public Element generateSetElementFromResults(List<E> returnedResults) { if (returnedResults == null) { throw new IllegalArgumentException("Argument 'returnedResults' cannot be null."); } final Element setElement = DocumentHelper .createElement(QName.get("set", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT)); // the size element contains the size of this entire result set. setElement.addElement("count").setText(String.valueOf(size())); // if the query wasn't a 'count only' query, add two more elements if (returnedResults.size() > 0) { final Element firstElement = setElement.addElement("first"); firstElement.addText(returnedResults.get(0).getUID()); firstElement.addAttribute("index", String.valueOf(indexOf(returnedResults.get(0)))); setElement.addElement("last").addText(returnedResults.get(returnedResults.size() - 1).getUID()); } return setElement; }
From source file:de.xaniox.bungeemode.BungeemodeAddon.java
License:Open Source License
@Override public void disable() { String gameName = config.getGame(); GameManager manager = getHeavySpleef().getGameManager(); if (manager.hasGame(gameName)) { Game game = manager.getGame(gameName); game.getEventBus().unregister(listener); }/* www .j a v a 2 s .c om*/ Bukkit.getMessenger().unregisterOutgoingPluginChannel(getHeavySpleef().getPlugin(), BUNGEECORD_CHANNEL); HandlerList.unregisterAll(listener); //Fix for HeavySpleef version 2.1 or below //that doesn't unload flags on add-on disable FlagRegistry reg = getHeavySpleef().getFlagRegistry(); for (Game game : manager.getGames()) { if (!game.isFlagPresent(FlagTeleportAll.class)) { continue; } FlagTeleportAll flag = game.getFlag(FlagTeleportAll.class); game.removeFlag(flag.getClass()); Element element = DocumentHelper.createElement("flag"); element.addAttribute("name", reg.getFlagPath(FlagTeleportAll.class)); flag.marshal(element); UnloadedFlag unloaded = new UnloadedFlag(); unloaded.setXmlElement(element); game.addFlag(unloaded, false); } }
From source file:de.xaniox.heavyspleef.core.flag.FlagRegistry.java
License:Open Source License
public void unregister(Class<? extends AbstractFlag<?>> flagClass) { String path = null;/*from w w w. j a va 2s . co m*/ for (Entry<DualKeyMap.DualKeyPair<String, Flag>, FlagClassHolder> entry : registeredFlagsMap.entrySet()) { FlagClassHolder holder = entry.getValue(); if (holder.flagClass != flagClass) { continue; } Flag annotation = entry.getKey().getSecondaryKey(); if (annotation.hasCommands()) { CommandManager manager = heavySpleef.getCommandManager(); manager.unregisterSpleefCommand(flagClass); } Iterator<Method> methodIterator = queuedInitMethods.iterator(); while (methodIterator.hasNext()) { Method method = methodIterator.next(); if (method.getDeclaringClass() == flagClass) { methodIterator.remove(); } } Unregister.Unregisterer.runUnregisterMethods(flagClass, heavySpleef, true, true); path = entry.getKey().getPrimaryKey(); for (Game game : heavySpleef.getGameManager().getGames()) { if (!game.isFlagPresent(flagClass)) { continue; } AbstractFlag<?> flag = game.getFlag(flagClass); game.removeFlag(flagClass); Element element = DocumentHelper.createElement("flag"); element.addAttribute("name", path); flag.marshal(element); UnloadedFlag unloaded = new UnloadedFlag(); unloaded.setXmlElement(element); game.addFlag(unloaded, false); } break; } if (path != null) { registeredFlagsMap.remove(path); } }
From source file:de.xaniox.heavyspleef.core.HeavySpleef.java
License:Open Source License
@SuppressWarnings("unchecked") public void reload() { loadConfigurations();//from ww w.jav a 2 s . co m DefaultConfig config = getConfiguration(ConfigType.DEFAULT_CONFIG); Locale locale = config.getLocalization().getLocale(); i18NManager.reloadAll(locale); moduleManager.reloadModules(); GeneralSection generalSection = config.getGeneralSection(); CommandManagerService service = commandManager.getService(); DefaultCommandExecution execution = service.getExecution(); spleefPrefix = generalSection.getSpleefPrefix() + " "; vipPrefix = generalSection.getVipPrefix(); execution.setPrefix(spleefPrefix); int pvpTimer = generalSection.getPvpTimer(); pvpTimerManager.setTicksNeeded(pvpTimer * 20L); for (Game game : gameManager.getGames()) { JoinRequester requester = game.getJoinRequester(); requester.setPvpTimerMode(pvpTimer > 0); List<AbstractFlag<?>> loadedFlags = Lists.newArrayList(); Iterator<AbstractFlag<?>> iterator = game.getFlagManager().getFlags().iterator(); while (iterator.hasNext()) { AbstractFlag<?> flag = iterator.next(); if (flag instanceof UnloadedFlag) { UnloadedFlag unloaded = (UnloadedFlag) flag; if (!unloaded.validateLoad(flagRegistry)) { //This is not ready for load yet continue; } AbstractFlag<?> loaded = unloaded.loadFlag(flagRegistry); loadedFlags.add(loaded); game.removeFlag(unloaded.getClass()); game.addFlag(loaded, false); } else { Class<? extends AbstractFlag<?>> clazz = (Class<? extends AbstractFlag<?>>) flag.getClass(); if (flagRegistry.isFlagPresent(clazz)) { continue; } //This flag has been deactivated game.removeFlag(clazz); /* Generate a path */ StringBuilder pathBuilder = new StringBuilder(); Flag parentFlagData = clazz.getAnnotation(Flag.class); do { pathBuilder.insert(0, parentFlagData.name()); Class<? extends AbstractFlag<?>> parentFlagClass = parentFlagData.parent(); parentFlagData = parentFlagClass.getAnnotation(Flag.class); if (parentFlagData != null && parentFlagClass != NullFlag.class) { pathBuilder.insert(0, FlagRegistry.FLAG_PATH_SEPERATOR); } } while (parentFlagData != null); String path = pathBuilder.toString(); Element element = DocumentHelper.createElement("flag"); element.addAttribute("name", path); flag.marshal(element); UnloadedFlag unloaded = new UnloadedFlag(); unloaded.setXmlElement(element); game.addFlag(unloaded, false); } } for (AbstractFlag<?> loaded : loadedFlags) { loaded.onFlagAdd(game); } } }
From source file:edu.ku.brc.specify.tasks.services.CollectingEventLocalityKMLGenerator.java
License:Open Source License
protected String generateHtmlDesc(CollectingEvent ce) { // get names of collectors List<String> agentNames = new Vector<String>(); for (Collector c : ce.getCollectors()) { if (StringUtils.isEmpty(c.getAgent().getFirstName())) { agentNames.add(c.getAgent().getLastName()); } else {/*ww w .ja v a2 s.co m*/ agentNames.add(c.getAgent().getFirstName() + " " + c.getAgent().getLastName()); } } // get taxonomy of collection object Hashtable<Pair<String, String>, CollectionObject> coHash = new Hashtable<Pair<String, String>, CollectionObject>(); Vector<Pair<String, String>> genusSpecies = new Vector<Pair<String, String>>(); for (CollectionObject co : ce.getCollectionObjects()) { String genus = null; String species = null; for (Determination d : co.getDeterminations()) { if (d.isCurrentDet()) { Taxon t = d.getPreferredTaxon(); species = t.getName(); genus = t.getParent().getName(); break; } } Pair<String, String> genusSpeciesPair = new Pair<String, String>(genus, species); genusSpecies.add(genusSpeciesPair); coHash.put(genusSpeciesPair, co); } DBTableInfo colObjTableInfo = DBTableIdMgr.getInstance().getInfoById(CollectionObject.getClassTableId()); DBFieldInfo catalogNumberFI = colObjTableInfo.getFieldByColumnName("CatalogNumber"); UIFieldFormatterIFace formatter = catalogNumberFI.getFormatter(); Element desc = DocumentHelper.createElement("div"); //sb.append("<center><h3>"); //sb.append(startString); //sb.append(" - "); //sb.append(endString); //sb.append("</h3></center><br/>"); desc.addElement("h3").addText(getResourceString("GE_COLLECTOR")); Element ul = desc.addElement("ul"); for (String agent : agentNames) { ul.addElement("li").addText(agent); } if (genusSpecies.size() > 0) { desc.addElement("br"); desc.addElement("h3").addText(getResourceString("GE_COLLECTION_OBJECTS")); Element table = desc.addElement("table"); AppPreferences remotePrefs = AppPreferences.getRemote(); String primaryURL = remotePrefs.get(PluginsTask.GE_BALLOON_PRIMARY_URL, null); String primaryURLTitle = remotePrefs.get(PluginsTask.GE_BALLOON_PRIMARY_URL_TITLE, null); String secondaryURL = remotePrefs.get(PluginsTask.GE_BALLOON_SECONDARY_URL, null); String secondaryURLTitle = remotePrefs.get(PluginsTask.GE_BALLOON_SECONDARY_URL_TITLE, null); Element tr = table.addElement("tr"); tr.addElement("th").addElement("center").addText(getResourceString("GE_CATALOG_NUMBER")); tr.addElement("th").addText(getResourceString("GE_TAXONOMY")); if (StringUtils.isNotEmpty(primaryURL)) { tr.addElement("th").addAttribute("style", "color:#" + textColor).addElement("center") .addText(getResourceString("GE_PRIMARY")); } if (StringUtils.isNotEmpty(secondaryURL)) { tr.addElement("th").addAttribute("style", "color:#" + textColor).addElement("center") .addText(getResourceString("GE_SECONDARY")); } for (Pair<String, String> tax : genusSpecies) { tr = table.addElement("tr"); tr.addElement("td").addElement("center") .addText((formatter != null) ? formatter.formatToUI(coHash.get(tax).getCatalogNumber()).toString() : coHash.get(tax).getCatalogNumber()); // simple name text String taxonomicName = (tax.first != null ? tax.first : "") + " " + (tax.second != null ? tax.second : ""); tr.addElement("td").addElement("i").addText(taxonomicName); String linkTextColor = (textColor.startsWith("F") ? "WHITE" : "BLACK"); if (StringUtils.isNotEmpty(primaryURL)) { String primaryURLStr = String.format(primaryURL, tax.first, tax.second); tr.addElement("td").addElement("center").addElement("a") .addAttribute("style", "color:" + linkTextColor).addAttribute("href", primaryURLStr) .addText(primaryURLTitle); } if (StringUtils.isNotEmpty(secondaryURL)) { String secondaryURLStr = String.format(secondaryURL, tax.first, tax.second); tr.addElement("td").addElement("center").addElement("a") .addAttribute("style", "color:" + linkTextColor).addAttribute("href", secondaryURLStr) .addText(secondaryURLTitle); } if (speciesToImageMapper != null) { String imgSrc = speciesToImageMapper.get(taxonomicName); //System.out.println("["+taxonomicName+"]["+imgSrc+"]"); if (imgSrc != null) { tr.addElement("td").addElement("img").addAttribute("src", imgSrc); } else { tr.addElement("td"); } } } } return XMLtoString(desc); }
From source file:edu.ku.brc.specify.tasks.services.CollectingEventLocalityKMLGenerator.java
License:Open Source License
private String generateHtmlDesc(Locality loc) { BigDecimal lat = loc.getLatitude1(); BigDecimal lon = loc.getLongitude1(); Element desc = DocumentHelper.createElement("div"); // desc.addElement("h3").addText(getResourceString("GE_LOCALITY")); Element table = desc.addElement("table"); Element tr = table.addElement("tr"); tr.addElement("td").addAttribute("style", "color:#" + textColor + "; text-align:right") .addText(getResourceString("Latitude") + ":"); tr.addElement("td").addAttribute("style", "color:#" + textColor).addText("" + lat.doubleValue()); tr = table.addElement("tr"); tr.addElement("td").addAttribute("style", "color:#" + textColor + "; text-align:right") .addText(getResourceString("Longitude") + ":"); tr.addElement("td").addAttribute("style", "color:#" + textColor).addText("" + lon.doubleValue()); if (loc.getGeography() != null) { tr = table.addElement("tr"); tr.addElement("td").addAttribute("style", "color:#" + textColor + "; text-align:right") .addText(getResourceString("Geography") + ":"); tr.addElement("td").addAttribute("style", "color:#" + textColor) .addText(loc.getGeography().getFullName()); }/*from w ww . j a va2 s. c om*/ return XMLtoString(desc); }
From source file:edu.ku.brc.specify.tasks.services.CollectingEventLocalityKMLGenerator.java
License:Open Source License
private String generateHtmlDesc(CollectionObject colObj) { CollectingEvent ce = colObj.getCollectingEvent(); Locality loc = ce.getLocality();//from w ww. ja va 2 s . c om BigDecimal lat = loc.getLatitude1(); BigDecimal lon = loc.getLongitude1(); //DBTableInfo coti = DBTableIdMgr.getInstance().getInfoById(CollectionObject.getClassTableId()); DBTableInfo ceti = DBTableIdMgr.getInstance().getInfoById(CollectingEvent.getClassTableId()); StringBuilder title = new StringBuilder(colObj.getIdentityTitle()); String taxonStr = null; String startDateStr = null; String geoStr = null; for (Determination det : colObj.getDeterminations()) { if (det.getIsCurrent()) { Taxon taxon = det.getTaxon(); if (taxon != null) { taxonStr = taxon.getFullName(); } } } if (ce.getStartDate() != null) { DBFieldInfo sdFI = ceti.getFieldByColumnName("StartDate"); UIFieldFormatterIFace fmtr = sdFI.getFormatter(); if (fmtr == null) { fmtr = UIFieldFormatterMgr.getInstance().getFormatter("PartialDate"); } if (fmtr != null) { Object dateFmtObj = fmtr.formatToUI(ce.getStartDate(), ce.getStartDatePrecision()); if (dateFmtObj != null) { startDateStr = dateFmtObj.toString(); } } } if (loc.getGeography() != null) { geoStr = loc.getGeography().getFullName(); } // sb.append( // DocumentHelper.createElement("h3") // .addText(getResourceString("GE_LOCALITY")+":").asXML()); Element table = DocumentHelper.createElement("table"); appendCellTR(table, CollectingEvent.getClassTableId(), "StartDate", "Start Date", startDateStr); appendCellTR(table, Taxon.getClassTableId(), null, "Taxon", taxonStr); appendCellTR(table, Locality.getClassTableId(), "Latitude1", "Latitude", convertToDDDDDD(loc.getLatitude1(), DEGREES_FORMAT.String, DIRECTION.NorthSouth, 4)); appendCellTR(table, Locality.getClassTableId(), "Longitude1", "Longitude", convertToDDDDDD(loc.getLongitude1(), DEGREES_FORMAT.String, DIRECTION.EastWest, 4)); appendCellTR(table, Geography.getClassTableId(), null, "Geography", geoStr); return XMLtoString(table); }