private boolean isSimple(YRichText yRichText){ List<YRichText.Part> parts = yRichText.toParts(); if(parts.size()==1){ return parts.get(0) instanceof YRichText.Leaf; } return false; }
private boolean isHtmlText(YRichText descriptionText) { if (descriptionText == null || descriptionText.isEmpty() || descriptionText.toParts().size() > 1) { return false; } Part part = descriptionText.toParts().get(0); if (!(part instanceof Node)) { return false; } Node node = (Node) part; return BaseYModelUtils.HTML_TAG.equals(node.getTag()) && BaseYModelUtils.XHTML_NAMESPACE.equals(node.getNS()); }
@Override public Object convert(YRichText text) { Object result = StringUtils.EMPTY; List<Part> parts = text.toParts(); if (CollectionUtils.isNotEmpty(parts)) { if (parts.size() == 1) { result = convertPart(parts.get(0)); } else { result = new BasicDBObject(YRichTextDbFields.F_CONTENT, convertParts(parts)); } } return result; }
private static YElement correctDescriptionsByScRemoval(YElement yelement) { for(YDescription yd : yelement.getDescriptions()){ removeGivenTag("sc", yd.getRichText().toParts()); } return yelement; }
private static YElement correctNamesByScRemoval(YElement yelement) { for(YName yn : yelement.getNames()){ removeGivenTag("sc", yn.getRichText().toParts()); } return yelement; }
private static YElement correctNamesByScRemoval(YElement yelement) { for(YName yn : yelement.getNames()){ removeGivenTag("sc", yn.getRichText().toParts()); } return yelement; }
private static YElement correctDescriptionsByScRemoval(YElement yelement) { for(YDescription yd : yelement.getDescriptions()){ removeGivenTag("sc", yd.getRichText().toParts()); } return yelement; }
@SuppressWarnings({ "rawtypes", "unchecked" }) private static YElement correctContentByPhantomRemoval(YElement yelement) { LinkedList<YContentEntry> ycel = new LinkedList<YContentEntry>(); for(YContentEntry yce : yelement.getContents()){ LinkedList<YName> ynl = new LinkedList<YName>(); for(YName yn : (List<YName>)(yce.getNames())){ List<Part> lp = putNameNodesIntoLeafs(yn.getRichText().toParts()); if(lp.size()>0){ yn.setText(new YRichText(lp)); ynl.add(yn); } } if(ynl.size()>0){ yce.setNames(ynl); ycel.add(yce); } } yelement.setContents(ycel); return yelement; }
private static YElement putRelationReferenceToLeafsIntoNodes(YElement yelement) { for(YRelation yr : yelement.getRelations()){ for(YAttribute ya : yr.getAttributes()){ if(! ll.contains(ya.getKey()))continue; removeGivenTag("sc", ya.getRichValue().toParts()); ya.setValue(new YRichText(extractLeafs(removeNodeWithGivenTag("ext-link", ya.getRichValue().toParts())))); } } return yelement; }
@SuppressWarnings({ "rawtypes", "unchecked" }) private static YElement correctContentByPhantomRemoval(YElement yelement) { LinkedList<YContentEntry> ycel = new LinkedList<YContentEntry>(); int i =0; for(YContentEntry yce : yelement.getContents()){ i++; // if(i==6){ // System.out.println(); // } LinkedList<YName> ynl = new LinkedList<YName>(); for(YName yn : (List<YName>)(yce.getNames())){ List<Part> lp = putNameNodesIntoLeafs(yn.getRichText().toParts()); if(lp.size()>0){ yn.setText(new YRichText(lp)); ynl.add(yn); } } if(ynl.size()>0){ yce.setNames(ynl); ycel.add(yce); } } yelement.setContents(ycel); return yelement; }
private static YElement putRelationReferenceToLeafsIntoNodes(YElement yelement) { for(YRelation yr : yelement.getRelations()){ // LinkedList<YAttribute> lya = new LinkedList<YAttribute>(); for(YAttribute ya : yr.getAttributes()){ if(! ll.contains(ya.getKey()))continue; removeGivenTag("sc", ya.getRichValue().toParts()); ya.setValue(new YRichText(extractLeafs(removeNodeWithGivenTag("ext-link", ya.getRichValue().toParts())))); // lya.add(ya); } // if(lya.size()>0)yr.setAttributes(lya); } return yelement; }
private static YElement putNameNodesIntoLeafs(YElement yelement) { for(YName yn : yelement.getNames()){ YRichText yrt = new YRichText(putNameNodesIntoLeafs(yn.getRichText().toParts())); yn.setText(yrt); } return yelement; }
private static YElement putNameLeafsIntoNodes(YElement yelement) { for(YName yn : yelement.getNames()){ YRichText yrt = new YRichText(putLeafsIntoNodes(yn.getRichText().toParts())); yn.setText(yrt); } return yelement; }
private static YElement putNameNodesIntoLeafs(YElement yelement) { for(YName yn : yelement.getNames()){ YRichText yrt = new YRichText(putNameNodesIntoLeafs(yn.getRichText().toParts())); yn.setText(yrt); } return yelement; }
private static YElement putNameLeafsIntoNodes(YElement yelement) { for(YName yn : yelement.getNames()){ YRichText yrt = new YRichText(putLeafsIntoNodes(yn.getRichText().toParts())); yn.setText(yrt); } return yelement; }
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; }
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) // if(p.toPlainText()!=null && !p.toPlainText().matches("[\\s]+")) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; } }
for (Part pt:yrt.toParts()) { Part p=removeInlineGraphicFixPubId(pt); if (p instanceof YRichText.Node) {
YAttribute title = relation.getOneAttribute(ReferenceAttributeTypes.AT_REFERENCE_PARSED_TITLE); if (title != null) { parts.addAll(title.getRichValue().toParts()); parts.add(new YRichText.Leaf(", "));