Example usage for org.dom4j Element addText

List of usage examples for org.dom4j Element addText

Introduction

In this page you can find the example usage for org.dom4j Element addText.

Prototype

Element addText(String text);

Source Link

Document

Adds a new Text node with the given text to this element.

Usage

From source file:cz.mzk.editor.server.newObject.FoxmlBuilder.java

License:Open Source License

protected void addRootTopic(Element modsRootEl) {
    if (getBundle() != null && getBundle().getMarc() != null) {
        String topic = getBundle().getMarc().getTopic();
        if (topic != null) {
            Element subjectEl = modsRootEl.addElement(new QName("subject", Namespaces.mods));
            Element topicEl = subjectEl.addElement(new QName("topic", Namespaces.mods));
            topicEl.addText(topic);
        }/* ww  w .  jav a  2s. c  o m*/
    }
}

From source file:cz.mzk.editor.server.newObject.FoxmlBuilder.java

License:Open Source License

protected void addRootPhysicalLocation(Element locationEl, boolean doDetach) {
    if (getBundle() != null && getBundle().getMarc() != null) {
        String location = getBundle().getMarc().getLocation();

        if (location != null) {
            //            Element shelfLocatorEl = (Element) shelfLocatorXpath.selectSingleNode(locationEl);
            //            String shelfLocatorStr = "";
            //            if (shelfLocatorEl != null) {
            //                shelfLocatorStr = shelfLocatorEl.getTextTrim();
            //                if (doDetach) shelfLocatorEl.detach();
            //            }
            Element physicalLocationEl = locationEl.addElement(new QName("physicalLocation", Namespaces.mods));
            physicalLocationEl.addText(location);
            //            shelfLocatorEl = locationEl.addElement(new QName("shelfLocator", Namespaces.mods));
            //            shelfLocatorEl.addText(shelfLocatorStr);
        }//from   w ww.jav a  2 s.c om
    }
}

From source file:cz.mzk.editor.server.newObject.FoxmlBuilder.java

License:Open Source License

protected void addRootUdcOrDdc(Element modsRootEl) {
    if (getBundle() != null && getBundle().getMarc() != null) {
        if (getBundle().getMarc().getUdcs() == null) {
            return;
        }//from w w w  .  ja va2s .  c o m
        List<String> udcs = getBundle().getMarc().getUdcs();
        for (String udc : udcs) {
            Element classificationEl = modsRootEl.addElement(new QName("classification", Namespaces.mods));
            classificationEl.addAttribute("authority", "udc");
            classificationEl.addText(udc);
        }
    }
}

From source file:cz.mzk.editor.server.newObject.IntPartBuilder.java

License:Open Source License

/**
 * {@inheritDoc}//from  www.  jav  a  2  s  . c om
 */
@Override
protected void decorateMODSStream() {
    Element modsCollection = FoxmlUtils.createModsCollectionEl();
    Namespace modsNs = Namespaces.mods;
    Element mods = modsCollection.addElement(new QName("mods", modsNs));
    mods.addAttribute("version", "3.3");
    mods.addAttribute("ID", getAditionalInfo());
    Element idUrn = mods.addElement(new QName("identifier", modsNs));
    idUrn.addAttribute("type", "urn");
    idUrn.addText(getUuid());

    Element titleInfo = mods.addElement(new QName("titleInfo", modsNs));
    Element title = titleInfo.addElement(new QName("title", modsNs));
    title.addText(getName());

    if (isNotNullOrEmpty(getNoteOrIntSubtitle())) {
        Element subtitle = titleInfo.addElement(new QName("subtitle", modsNs));
        subtitle.addText(getNoteOrIntSubtitle());
    }
    if (isNotNullOrEmpty(getPartNumber())) {
        Element partNumber = titleInfo.addElement(new QName("partNumber", modsNs));
        partNumber.addText(getPartNumber());
    }
    if (isNotNullOrEmpty(getDateOrIntPartName())) {
        Element partName = titleInfo.addElement(new QName("partName", modsNs));
        partName.addText(getDateOrIntPartName());
    }

    Element genre = mods.addElement(new QName("genre", modsNs));
    genre.addAttribute("type", getType());
    String levelName = getAditionalInfo().substring(0, getAditionalInfo().indexOf("_", 6));
    genre.addText(INTERNAL_PART_LEVEL_NAMES.MAP.get(levelName));

    Element part = mods.addElement(new QName("part", modsNs));
    Element extent = part.addElement(new QName("extent", modsNs));

    List<RelsExtRelation> children = getChildren();
    Element start = extent.addElement(new QName("start", modsNs));
    start.addText(children.get(0).getTargetName());
    Element end = extent.addElement(new QName("end", modsNs));
    end.addText(children.get(children.size() - 1).getTargetName());
    Element total = extent.addElement(new QName("total", modsNs));
    total.addText(String.valueOf(children.size()));

    addRootLanguage(mods);
    addIdentifierUuid(mods, getUuid());
    addRootRecordInfo(mods.addElement(new QName("recordInfo", modsNs)));
    addRootTopic(mods);
    addLocation(mods.addElement(new QName("location", modsNs)));

    appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null);

}

From source file:cz.mzk.editor.server.newObject.MonographBuilder.java

License:Open Source License

@SuppressWarnings("unchecked")
private void updateDcDoc(Document dcDoc, String pid, String signature, String sysno, DigitalObjectModel model) {
    Element dcRootEl = dcDoc.getRootElement();
    Attribute schemaLoc = dcRootEl.attribute("schemaLocation");
    dcRootEl.remove(schemaLoc);/*  w  w  w  .  j  a v  a 2 s .  co m*/
    Namespace xsi = DocumentHelper.createNamespace("xsi2", FedoraNamespaces.SCHEMA_NAMESPACE_URI);
    dcRootEl.add(xsi);
    dcRootEl.addAttribute(new QName("schemaLocation", xsi),
            "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");

    XPath typeXpath = Dom4jUtils.createXPath("/oai_dc:dc/dc:identifier");
    List<? extends Node> nodes = typeXpath.selectNodes(dcDoc);
    for (Node node : nodes) {
        node.detach();
    }
    Element idUuid = dcRootEl.addElement("dc:identifier");
    idUuid.addText(pid);

    for (Node node : nodes) {
        if (node.getText() != null && !"".equals(node.getText().trim())
                && !node.getText().contains(Constants.FEDORA_UUID_PREFIX)) {
            Element temp = dcRootEl.addElement("dc:identifier");
            temp.addText(node.getText());
        }
    }

    if (signature != null) {
        Element idSignature = dcRootEl.addElement("dc:identifier");
        idSignature.addText("signature:" + signature);
    }
    if (sysno != null) {
        Element idSysno = dcRootEl.addElement("dc:identifier");
        idSysno.addText("sysno:" + sysno);
    }
    removeDcTypeElements(dcDoc);
    Element typeEl = dcRootEl.addElement("dc:type");
    typeEl.addText("model:" + model.getValue());
    Element rightsEl = dcRootEl.addElement("dc:rights");
    rightsEl.addText("policy:" + getPolicy().toString().toLowerCase());
    updateDcLanguages(dcDoc);
}

From source file:cz.mzk.editor.server.newObject.MonographBuilder.java

License:Open Source License

@SuppressWarnings("unchecked")
private void updateLanguages(Document doc, XPath xpath) {
    List<? extends Node> nodes = xpath.selectNodes(doc);
    for (Node languageNode : nodes) {
        Element languageEl = (Element) languageNode;
        String originalLang = languageEl.getTextTrim();
        languageEl.clearContent();//from www  .ja  v  a  2s. c om
        languageEl.addText(transformLanguage(originalLang));
    }
}

From source file:cz.mzk.editor.server.newObject.MonographBuilder.java

License:Open Source License

private void addLinks(Document modsDoc, MarcSpecificMetadata marc, String uuid) {
    Element copyInformation = (Element) copyInformationXpath.selectSingleNode(modsDoc);
    copyInformation.addElement(new QName("electronicLocator", Namespaces.mods));
    copyInformation.addText(alephLink(marc));

    Element location = (Element) locationXpath.selectSingleNode(modsDoc);
    addLocation(location);//w  ww. j  a va  2  s. c o  m
}

From source file:cz.mzk.editor.server.newObject.MonographUnitBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*from   ww w  .  j a va  2s. c  o  m*/
 */
@Override
protected void decorateMODSStream() {
    Element modsCollection = FoxmlUtils.createModsCollectionEl();
    Namespace modsNs = Namespaces.mods;
    Element mods = modsCollection.addElement(new QName("mods", modsNs));
    mods.addAttribute("version", "3.3");
    mods.addAttribute("ID", getAditionalInfo());
    Element idUrn = mods.addElement(new QName("identifier", modsNs));
    idUrn.addAttribute("type", "urn");
    idUrn.addText(getUuid());

    Element titleInfo = mods.addElement(new QName("titleInfo", modsNs));

    addRootTitle(titleInfo.addElement(new QName("title", modsNs)));

    if (isNotNullOrEmpty(getPartNumber())) {
        Element partNumber = titleInfo.addElement(new QName("partNumber", modsNs));
        partNumber.addText(getPartNumber());
    }
    if (isNotNullOrEmpty(getName())) {
        Element partName = titleInfo.addElement(new QName("partName", modsNs));
        partName.addText(getName());
    }

    Element genre = mods.addElement(new QName("genre", modsNs));
    String levelName = getAditionalInfo().substring(0, getAditionalInfo().indexOf("_", 6));
    genre.addText(Constants.MONOGRAPH_UNIT_LEVEL_NAMES.MAP.get(levelName));

    Element originInfo = mods.addElement(new QName("originInfo", modsNs));
    Element dateIssued = originInfo.addElement(new QName("dateIssued", modsNs));
    if (isNotNullOrEmpty(getDateOrIntPartName())) {
        dateIssued.addText(getDateOrIntPartName());
    } else {
        dateIssued.addAttribute("qualifier", "approximate");
    }

    addRootPlace(originInfo);
    addRootPublisher(originInfo);
    addRootLanguage(mods);
    addRootTopic(mods);

    Element physicalDescription = addRootPhysicalDescriptionForm(mods);
    if (isNotNullOrEmpty(getNoteOrIntSubtitle())) {
        Element noteEl = physicalDescription.addElement(new QName("note", modsNs));
        noteEl.addText(getNoteOrIntSubtitle());
    }

    addIdentifierUuid(mods, getUuid());

    appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null);
}

From source file:cz.mzk.editor.server.newObject.PageBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*w w w.  j ava  2 s  .  com*/
 */
@Override
protected void decorateMODSStream() {
    String pageLabel = getName();
    Element modsCollection = FoxmlUtils.createModsCollectionEl();
    Namespace modsNs = Namespaces.mods;
    Element mods = modsCollection.addElement(new QName("mods", modsNs));
    mods.addAttribute("version", "3.3");
    Element idUrn = mods.addElement(new QName("identifier", modsNs));
    idUrn.addAttribute("type", "urn");
    idUrn.addText(getUuid());

    Element idSici = mods.addElement(new QName("identifier", modsNs));
    idSici.addAttribute("type", "sici");

    Element titleInfo = mods.addElement(new QName("titleInfo", modsNs));
    Element title = titleInfo.addElement(new QName("title", modsNs));
    title.addText(pageLabel);

    Element typeOfResource = mods.addElement(new QName("typeOfResource", modsNs));
    typeOfResource.addText("text");
    Element part = mods.addElement(new QName("part", modsNs));
    String resolvedPageType = Constants.PAGE_TYPES.MAP.get(getType());
    part.addAttribute("type", resolvedPageType == null ? "NormalPage" : resolvedPageType);
    //pageNumber
    Element detail = part.addElement(new QName("detail", modsNs));
    detail.addAttribute("type", Constants.MODS_PART_DETAIL_PAGE_NUMBER);

    Element number = null;
    if (pageLabel.contains(Constants.TWO_PAGES_SEPARATOR)) {
        String[] splitedLabel = pageLabel.split("\\" + Constants.TWO_PAGES_SEPARATOR);
        number = detail.addElement(new QName("number", modsNs));
        number.addText(splitedLabel[0]);
        number = detail.addElement(new QName("number", modsNs));
        number.addText(splitedLabel[1]);
    } else {
        number = detail.addElement(new QName("number", modsNs));
        number.addText(pageLabel);
    }
    //page index
    detail = part.addElement(new QName("detail", modsNs));
    detail.addAttribute("type", "pageIndex");
    number = detail.addElement(new QName("number", modsNs));
    number.addText(String.valueOf(getPageIndex()));

    addLocation(mods.addElement(new QName("location", modsNs)));
    addIdentifierUuid(mods, getUuid());

    appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null);
}

From source file:cz.mzk.editor.server.newObject.PageBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w  w w  .  j  a  v a 2  s . c o m*/
 */
@Override
protected void decorateRelsExtStream() {
    super.decorateRelsExtStream();

    Element description = FoxmlUtils.findDescriptionElement(getRelsExtXmlContent());
    Element url = description.addElement(new QName("tiles-url", Namespaces.kramerius));
    url.addText(getImageUrl());
}