List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeXml
public static final String unescapeXml(final String input)
Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
Supports only the five basic XML entities (gt, lt, quot, amp, apos).
From source file:fr.mcc.ginco.exports.skos.SKOSTermsExporter.java
/** * Export concept not preferred terms to SKOS using the skos API * * @param conceptId/*from w ww.j av a 2s .c om*/ * @param model * @param conceptResource * @return list of concept not preferred terms for skos */ public Model exportConceptNotPreferredTerms(String conceptId, Model model, Resource conceptResource) { for (ThesaurusTerm altLabel : thesaurusTermService.getTermsByConceptId(conceptId)) { if (altLabel.getPrefered()) { continue; } if (altLabel.getHidden()) { model.add(conceptResource, SKOS.HIDDEN_LABEL, StringEscapeUtils.unescapeXml(altLabel.getLexicalValue()), altLabel.getLanguage().getId()); } else { model.add(conceptResource, SKOS.ALT_LABEL, StringEscapeUtils.unescapeXml(altLabel.getLexicalValue()), altLabel.getLanguage().getId()); } skosModelTermsExporter.exportConceptNotPreferredTerm(altLabel, model, conceptResource, altLabel.getHidden()); } return model; }
From source file:fr.mcc.ginco.exports.skos.SKOSModelTermsExporter.java
public Model exportConceptNotPreferredTerm(ThesaurusTerm term, Model model, Resource conceptResource, boolean hidden) { logger.debug("Start generating model for non preferred term " + term.getLexicalValue() + "(hidden = " + hidden + ")"); Resource prefTermRes = model.createResource(term.getIdentifier(), ISOTHES.SIMPLE_NON_PREFERRED_TERM); model.add(prefTermRes, DCTerms.created, DateUtil.toISO8601String(term.getCreated())); model.add(prefTermRes, DCTerms.modified, DateUtil.toISO8601String(term.getModified())); model.add(prefTermRes, SKOSXL.LITERAL_FORM, StringEscapeUtils.unescapeXml(term.getLexicalValue()), term.getLanguage().getId()); model.add(prefTermRes, ISOTHES.STATUS, term.getStatus().toString()); if (hidden) { conceptResource.addProperty(SKOSXL.HIDDEN_LABEL, prefTermRes); } else {//ww w . j ava2s . com conceptResource.addProperty(SKOSXL.ALT_LABEL, prefTermRes); } if (StringUtils.isNotEmpty(term.getSource())) { model.add(prefTermRes, DC.source, StringEscapeUtils.unescapeXml(term.getSource())); } return model; }
From source file:fr.mcc.ginco.audit.commands.SynonymsCommandBuilder.java
/** * Builds the list of command lines for synonyms changes between two * revisions//from ww w. ja v a 2 s. c om * @param previousConcepts * @param currentConcepts * @param oldRevision * @param currentRevision * @param lang * @return */ public List<CommandLine> buildSynonyms(List<ThesaurusConcept> previousConcepts, List<ThesaurusConcept> currentConcepts, Number oldRevision, Number currentRevision, String lang) { List<CommandLine> termsOperations = new ArrayList<CommandLine>(); Map<String, List<String>> previousSynonyms = mistralStructuresBuilder .buildSynonymsStructure(previousConcepts, oldRevision, lang); Map<String, List<String>> currentSynonyms = mistralStructuresBuilder.buildSynonymsStructure(currentConcepts, currentRevision, lang); // Check for existence/non existence of previous synonyms for (String previousSynonym : previousSynonyms.keySet()) { if (currentSynonyms.containsKey(previousSynonym)) { if (!ListUtils.isEqualList(previousSynonyms.get(previousSynonym), currentSynonyms.get(previousSynonym))) { // Change of synonyms list for (String termValue : previousSynonyms.get(previousSynonym)) { if (!currentSynonyms.get(previousSynonym).contains(termValue)) { // Synonym has been removed from list CommandLine synonymRemovedLine = new CommandLine(); synonymRemovedLine .setValue(CommandLine.SEPARATE + StringEscapeUtils.unescapeXml(termValue)); termsOperations.add(synonymRemovedLine); } } for (String termValue : currentSynonyms.get(previousSynonym)) { if (!previousSynonyms.get(previousSynonym).contains(termValue)) { // Synonym has been added to list CommandLine synonymAddedLine = new CommandLine(); synonymAddedLine.setValue(StringEscapeUtils.unescapeXml(previousSynonym) + CommandLine.SYNONYM + StringEscapeUtils.unescapeXml(termValue)); termsOperations.add(synonymAddedLine); } } } } else { // Synonyms suppression for (String prevSynonymValue : previousSynonyms.get(previousSynonym)) { CommandLine synonymRemovedLine = new CommandLine(); synonymRemovedLine .setValue(CommandLine.SEPARATE + StringEscapeUtils.unescapeXml(prevSynonymValue)); termsOperations.add(synonymRemovedLine); } } } // Check for addition of synonyms relations for (String currentSynonym : currentSynonyms.keySet()) { if (!previousSynonyms.containsKey(currentSynonym) && currentSynonyms.get(currentSynonym).size() > 0) { CommandLine synonymsAddedLine = new CommandLine(); String lineValue = StringEscapeUtils.unescapeXml(currentSynonym); for (String synonym : currentSynonyms.get(currentSynonym)) { lineValue += CommandLine.SYNONYM + StringEscapeUtils.unescapeXml(synonym); } synonymsAddedLine.setValue(lineValue); termsOperations.add(synonymsAddedLine); } } return termsOperations; }
From source file:fr.mcc.ginco.exports.skos.SKOSGroupExporter.java
public void exportGroup(Thesaurus thesaurus, ThesaurusConceptGroup group, Model model) { ThesaurusConceptGroupLabel label = thesaurusConceptGroupLabelService .getByThesaurusConceptGroup(group.getIdentifier()); Resource groupRes = model.createResource(group.getIdentifier(), GINCO.getResource(group.getConceptGroupType().getSkosLabel())); Resource inScheme = model.createResource(thesaurus.getIdentifier()); model.add(groupRes, SKOS.IN_SCHEME, inScheme); model.add(groupRes, DCTerms.created, DateUtil.toISO8601String(label.getCreated())); model.add(groupRes, DCTerms.modified, DateUtil.toISO8601String(label.getModified())); model.add(groupRes, RDFS.label, StringEscapeUtils.unescapeXml(label.getLexicalValue()), label.getLanguage().getId()); String notation = group.getNotation(); if (StringUtils.isNotEmpty(notation)) { model.add(groupRes, SKOS.NOTATION, StringEscapeUtils.unescapeXml(group.getNotation())); }// w ww. j ava2 s.c o m List<ThesaurusConcept> concepts = new ArrayList<ThesaurusConcept>(); if (group.getIsDynamic() != null && group.getIsDynamic()) { if (group.getParentConcept() != null) { concepts = thesaurusConceptService .getRecursiveChildrenByConceptId(group.getParentConcept().getIdentifier()); concepts.add(group.getParentConcept()); } } else { if (group.getConcepts() != null) { concepts.addAll(group.getConcepts()); } } for (ThesaurusConcept concept : concepts) { Resource conceptRes = model.createResource(concept.getIdentifier()); model.add(groupRes, SKOS.MEMBER, conceptRes); } ThesaurusConceptGroup parentGroup = group.getParent(); if (parentGroup != null) { Resource parentRes = ResourceFactory.createResource(parentGroup.getIdentifier()); model.add(groupRes, ISOTHES.SUPER_GROUP, parentRes); } List<ThesaurusConceptGroup> childGroups = thesaurusConceptGroupService .getChildGroups(group.getIdentifier()); if (!childGroups.isEmpty()) { for (ThesaurusConceptGroup childGroup : childGroups) { Resource childRes = ResourceFactory.createResource(childGroup.getIdentifier()); model.add(groupRes, ISOTHES.SUB_GROUP, childRes); } } }
From source file:fr.mcc.ginco.audit.commands.HierarchyCommandBuilder.java
/** * Builds the list of command lines for hierarchy changes between two * revisions//from w w w. j a v a 2 s . co m * * @param previousConcepts * @param currentConcepts * @param oldRevision * @param currentRevision * @param lang * @return */ public List<CommandLine> buildHierarchyChanges(List<ThesaurusConcept> previousConcepts, List<ThesaurusConcept> currentConcepts, Number oldRevision, Number currentRevision, String lang) { List<CommandLine> termsOperations = new ArrayList<CommandLine>(); Map<String, List<String>> previousHierarchies = mistralStructuresBuilder .buildHierarchyStructure(previousConcepts, oldRevision, lang); Map<String, List<String>> currentHierarchies = mistralStructuresBuilder .buildHierarchyStructure(currentConcepts, currentRevision, lang); for (String previousParentConceptId : previousHierarchies.keySet()) { if (currentHierarchies.containsKey(previousParentConceptId)) { // Concept still exists if (!ListUtils.isEqualList(previousHierarchies.get(previousParentConceptId), currentHierarchies.get(previousParentConceptId))) { // but hierarchy has changed for (String oldChild : previousHierarchies.get(previousParentConceptId)) { if (!currentHierarchies.get(previousParentConceptId).contains(oldChild)) { // child removed CommandLine childRemovedLine = new CommandLine(); childRemovedLine.setValue(CommandLine.HIERARCHY_REMOVED + StringEscapeUtils.unescapeXml(oldChild) + CommandLine.HIERARCHY + StringEscapeUtils.unescapeXml(previousParentConceptId)); termsOperations.add(childRemovedLine); } } for (String newChild : currentHierarchies.get(previousParentConceptId)) { if (!previousHierarchies.get(previousParentConceptId).contains(newChild)) { // child added CommandLine childAddedLine = new CommandLine(); childAddedLine.setValue(StringEscapeUtils.unescapeXml(newChild) + CommandLine.HIERARCHY + StringEscapeUtils.unescapeXml(previousParentConceptId)); termsOperations.add(childAddedLine); } } } } else { // Concept does not exist anymore, remove all old hierarchies for (String oldChild : previousHierarchies.get(previousParentConceptId)) { CommandLine childRemovedLine = new CommandLine(); childRemovedLine.setValue(CommandLine.HIERARCHY_REMOVED + StringEscapeUtils.unescapeXml(oldChild) + CommandLine.HIERARCHY + StringEscapeUtils.unescapeXml(previousParentConceptId)); termsOperations.add(childRemovedLine); } } } for (String currentParentConceptId : currentHierarchies.keySet()) { if (!previousHierarchies.containsKey(currentParentConceptId)) { // Add all new hierarchies for (String child : currentHierarchies.get(currentParentConceptId)) { CommandLine hierarchyAddedLine = new CommandLine(); hierarchyAddedLine.setValue(StringEscapeUtils.unescapeXml(child) + CommandLine.HIERARCHY + StringEscapeUtils.unescapeXml(currentParentConceptId)); termsOperations.add(hierarchyAddedLine); } } } return termsOperations; }
From source file:fr.mcc.ginco.data.FullThesaurus.java
public void setSubject(String subject) { this.subject = StringEscapeUtils.unescapeXml(subject); }
From source file:ac.ucy.cs.spdx.service.SpdxViolationAnalysis.java
@POST @Path("/validate/") @Consumes(MediaType.TEXT_PLAIN)//w ww. j a va 2s. c o m @Produces(MediaType.APPLICATION_JSON) public String validateSpdx(String jsonString) throws InvalidSPDXAnalysisException { ObjectMapper mapper = new ObjectMapper(); JsonNode fileNode = null; try { fileNode = mapper.readTree(jsonString); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String fileName = fileNode.get("filename").toString(); fileName = fileName.substring(1, fileName.length() - 1); String content = fileNode.get("content").toString(); content = StringEscapeUtils.unescapeXml(content); content = content.substring(1, content.length() - 1); SpdxLicensePairConflictError analysis = null; CaptureLicense captured = null; try { captured = new CaptureLicense(ParseRdf.parseToRdf(fileName, content)); } catch (InvalidLicenseStringException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { analysis = new SpdxLicensePairConflictError(captured); } catch (UnsupportedSpdxVersionException e) { e.printStackTrace(); } return analysis.toJson();// {"filename":"","content":""} }
From source file:msearch.tool.MSFunktionen.java
public static void unescape(DatenFilm film) { film.arr[DatenFilm.FILM_THEMA_NR] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_THEMA_NR].trim()); film.arr[DatenFilm.FILM_THEMA_NR] = StringEscapeUtils .unescapeHtml4(film.arr[DatenFilm.FILM_THEMA_NR].trim()); // Beschreibung film.arr[DatenFilm.FILM_BESCHREIBUNG_NR] = StringEscapeUtils .unescapeXml(film.arr[DatenFilm.FILM_BESCHREIBUNG_NR].trim()); film.arr[DatenFilm.FILM_BESCHREIBUNG_NR] = StringEscapeUtils .unescapeHtml4(film.arr[DatenFilm.FILM_BESCHREIBUNG_NR].trim()); film.arr[DatenFilm.FILM_BESCHREIBUNG_NR] = removeHtml(film.arr[DatenFilm.FILM_BESCHREIBUNG_NR]); // Titel/*from w w w . ja v a 2 s . c o m*/ film.arr[DatenFilm.FILM_TITEL_NR] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_TITEL_NR].trim()); film.arr[DatenFilm.FILM_TITEL_NR] = StringEscapeUtils .unescapeHtml4(film.arr[DatenFilm.FILM_TITEL_NR].trim()); }
From source file:fr.mcc.ginco.audit.commands.TermCommandBuilder.java
/** * Builds the list of command lines for terms changed between two revisions * * @param previousTerms//from www . ja v a 2s .c om * @param currentTerms * @return */ public List<CommandLine> buildChangedTermsLines(List<ThesaurusTerm> previousTerms, List<ThesaurusTerm> currentTerms) { List<CommandLine> termsOperations = new ArrayList<CommandLine>(); Map<String, ThesaurusTerm> newLexicalvalues = mistralStructuresBuilder.getTermVersionsView(currentTerms); Map<String, List<ThesaurusTerm>> newNotPreferredTermsByTerm = mistralStructuresBuilder .getNotPreferredTermsByTerm(currentTerms); for (ThesaurusTerm oldTerm : previousTerms) { if (newLexicalvalues.containsKey(oldTerm.getLexicalValue())) { if (oldTerm.getPrefered() != newLexicalvalues.get(oldTerm.getLexicalValue()).getPrefered()) { if (!oldTerm.getPrefered()) { CommandLine preferredLine = new CommandLine(); if (newNotPreferredTermsByTerm.get(oldTerm.getLexicalValue()).isEmpty()) { preferredLine.setValue(StringEscapeUtils.unescapeXml(oldTerm.getLexicalValue())); } else { preferredLine.setValue( CommandLine.STARS + StringEscapeUtils.unescapeXml(oldTerm.getLexicalValue())); } termsOperations.add(preferredLine); } else { CommandLine unpreferredLine = new CommandLine(); unpreferredLine.setValue(CommandLine.UNPREFERRERD + StringEscapeUtils.unescapeXml(oldTerm.getLexicalValue())); termsOperations.add(unpreferredLine); } } } } return termsOperations; }
From source file:mSearch.tool.Functions.java
public static void unescape(DatenFilm film) { film.arr[DatenFilm.FILM_THEMA] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_THEMA].trim()); film.arr[DatenFilm.FILM_THEMA] = StringEscapeUtils.unescapeHtml4(film.arr[DatenFilm.FILM_THEMA].trim()); // Beschreibung film.arr[DatenFilm.FILM_BESCHREIBUNG] = StringEscapeUtils .unescapeXml(film.arr[DatenFilm.FILM_BESCHREIBUNG].trim()); film.arr[DatenFilm.FILM_BESCHREIBUNG] = StringEscapeUtils .unescapeHtml4(film.arr[DatenFilm.FILM_BESCHREIBUNG].trim()); film.arr[DatenFilm.FILM_BESCHREIBUNG] = removeHtml(film.arr[DatenFilm.FILM_BESCHREIBUNG]); // Titel/*from www . j ava2s . com*/ film.arr[DatenFilm.FILM_TITEL] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_TITEL].trim()); film.arr[DatenFilm.FILM_TITEL] = StringEscapeUtils.unescapeHtml4(film.arr[DatenFilm.FILM_TITEL].trim()); }