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.fi.muni.xkremser.editor.server.newObject.PeriodicalItemBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*from w w w  . j  a v  a2 s  .  c  om*/
 */
@Override
protected void decorateMODSStream() {
    String volumeLabel = getLabel();
    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 titleInfo = mods.addElement(new QName("titleInfo", modsNs));
    Element title = titleInfo.addElement(new QName("title", modsNs));
    title.addText(volumeLabel);

    String typeOfResource = getTypeOfResource();
    if (typeOfResource != null) {
        Element typeOfResourceEl = mods.addElement(new QName("typeOfResource", modsNs));
        typeOfResourceEl.addText(getTypeOfResource());
    }

    Element genre = mods.addElement(new QName("genre", modsNs));
    genre.addAttribute("type", "issue");

    Element originInfo = mods.addElement(new QName("originInfo", modsNs));
    Element dateIssued = originInfo.addElement(new QName("dateIssued", modsNs));
    dateIssued.addText(getDateIssued() != null ? getDateIssued() : "");
    Element issuance = originInfo.addElement(new QName("issuance", modsNs));
    issuance.addText("continuing");

    String language = getLanguage();
    if (language != null) {
        Element languageEl = mods.addElement(new QName("language", modsNs));
        Element languageTerm = languageEl.addElement(new QName("languageTerm", modsNs));
        languageTerm.addAttribute("type", "code");
        languageTerm.addAttribute("authority", "iso639-2b");
        languageTerm.addText(language);
    }

    Element part = mods.addElement(new QName("part", modsNs));
    Element detail = part.addElement(new QName("detail", modsNs));
    detail.addAttribute("type", "issue");
    Element number = detail.addElement(new QName("number", modsNs));
    number.addText(volumeLabel);

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

}

From source file:cz.fi.muni.xkremser.editor.server.newObject.PeriodicalVolumeBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*  w w  w.  j a v  a2s .co  m*/
 */
@Override
protected void decorateMODSStream() {
    String volumeLabel = getLabel();
    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 titleInfo = mods.addElement(new QName("titleInfo", modsNs));
    Element title = titleInfo.addElement(new QName("title", modsNs));
    title.addText(volumeLabel);

    String typeOfResource = getTypeOfResource();
    if (typeOfResource != null) {
        Element typeOfResourceEl = mods.addElement(new QName("typeOfResource", modsNs));
        typeOfResourceEl.addText(getTypeOfResource());
    }

    Element genre = mods.addElement(new QName("genre", modsNs));
    genre.addAttribute("type", "volume");

    Element originInfo = mods.addElement(new QName("originInfo", modsNs));
    Element dateIssued = originInfo.addElement(new QName("dateIssued", modsNs));
    dateIssued.addText(getDateIssued() != null ? getDateIssued() : "");
    Element issuance = originInfo.addElement(new QName("issuance", modsNs));
    issuance.addText("continuing");

    String language = getLanguage();
    if (language != null) {
        Element languageEl = mods.addElement(new QName("language", modsNs));
        Element languageTerm = languageEl.addElement(new QName("languageTerm", modsNs));
        languageTerm.addAttribute("type", "code");
        languageTerm.addAttribute("authority", "iso639-2b");
        languageTerm.addText(language);
    }

    Element part = mods.addElement(new QName("part", modsNs));
    Element detail = part.addElement(new QName("detail", modsNs));
    detail.addAttribute("type", "volume");
    Element number = detail.addElement(new QName("number", modsNs));
    number.addText(volumeLabel);

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

}

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);// w  ww .j  a v a 2  s  .com
    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:cz.mzk.editor.server.newObject.FoxmlBuilder.java

License:Open Source License

protected void addRootLanguage(Element modsRootEl) {
    ModsTypeClient mods = getFirstMods();
    if (mods != null && mods.getLanguage() != null && mods.getLanguage().size() > 0
            && mods.getLanguage().get(0).getLanguageTerm() != null
            && mods.getLanguage().get(0).getLanguageTerm().size() > 0
            && mods.getLanguage().get(0).getLanguageTerm().get(0) != null
            && isNotNullOrEmpty(mods.getLanguage().get(0).getLanguageTerm().get(0).getValue())) {

        Element languageEl = modsRootEl.addElement(new QName("language", Namespaces.mods));
        Element languageTerm = languageEl.addElement(new QName("languageTerm", Namespaces.mods));
        languageTerm.addAttribute("type", "code");
        languageTerm.addAttribute("authority", "iso639-2b");
        languageTerm.addText(mods.getLanguage().get(0).getLanguageTerm().get(0).getValue());
    }//  ww  w .  ja  v  a  2  s .  co  m
}

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

License:Open Source License

protected void addIdentifierUuid(Element modsRootElement, String uuid) {
    Element identifier = modsRootElement.addElement(new QName("identifier", Namespaces.mods));
    identifier.addAttribute("type", "uuid");
    identifier.addText("uuid:" + uuid);
}

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

License:Open Source License

protected void addRootPlace(Element originInfoEl) {
    ModsTypeClient mods = getFirstMods();
    PlaceTypeClient placeClient = null;/*from  www . j  a v  a2  s  .co  m*/
    if (mods != null && mods.getOriginInfo() != null && mods.getOriginInfo().size() > 0
            && mods.getOriginInfo().get(0).getPlace() != null
            && mods.getOriginInfo().get(0).getPlace().size() > 0)
        placeClient = mods.getOriginInfo().get(0).getPlace().get(0);

    if (placeClient != null && placeClient.getPlaceTerm() != null && placeClient.getPlaceTerm().size() > 0) {
        String authority = placeClient.getPlaceTerm().get(0).getAuthority().value();
        String type = placeClient.getPlaceTerm().get(0).getType().value();
        String place = placeClient.getPlaceTerm().get(0).getValue();
        if (authority != null && type != null && place != null) {
            Element placeEl = originInfoEl.addElement(new QName("place", Namespaces.mods));
            Element placeTermEl = placeEl.addElement(new QName("placeTerm", Namespaces.mods));
            placeTermEl.addAttribute("type", type);
            placeTermEl.addAttribute("authority", authority);
            placeTermEl.addText(place);
        }
    }
}

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

License:Open Source License

protected void addRootPublisher(Element originInfoEl) {
    if (getBundle() != null && getBundle().getMarc() != null) {
        String name = getBundle().getMarc().getPublisher();
        if (isNotNullOrEmpty(name)) {
            Element publisher = originInfoEl.addElement(new QName("publisher", Namespaces.mods));
            publisher.addText(name);
        }/*from w w w. j av a  2 s.co  m*/
    }
}

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

License:Open Source License

protected Element addRootPhysicalDescriptionForm(Element modsRootEl) {
    ModsTypeClient mods = getFirstMods();
    List<StringPlusAuthorityPlusTypeClient> physDescForms = null;
    Element physDescEl = modsRootEl.addElement(new QName("physicalDescription", Namespaces.mods));

    if (mods != null && mods.getPhysicalDescription() != null && mods.getPhysicalDescription().size() > 0
            && mods.getPhysicalDescription().get(0).getForm() != null
            && mods.getPhysicalDescription().get(0).getForm().size() > 0) {
        physDescForms = mods.getPhysicalDescription().get(0).getForm();

        for (StringPlusAuthorityPlusTypeClient physDescForm : physDescForms) {
            String authority = physDescForm.getAuthority();
            String form = physDescForm.getValue();
            if (authority != null && form != null) {
                Element formEl = physDescEl.addElement(new QName("form", Namespaces.mods));
                formEl.addAttribute("authority", authority);
                formEl.addText(form);
            }//w w w.j a  v  a2 s  . com
        }
    }
    return physDescEl;
}

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

License:Open Source License

protected void addLocation(Element locationEl) {
    Element url = locationEl.addElement(new QName("url", Namespaces.mods));
    url.addText(configuration.getKrameriusHost() + "/handle/uuid:" + uuid);
}

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

License:Open Source License

protected void addRootRecordInfo(Element recordInfoEl) {
    Date now = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    String nowStr = sdf.format(now);
    Element creationDate = recordInfoEl.addElement(new QName("recordCreationDate", Namespaces.mods));
    creationDate.addAttribute("encoding", "iso8601");
    creationDate.addText(nowStr);
    Element changeDate = recordInfoEl.addElement(new QName("recordChangeDate", Namespaces.mods));
    changeDate.addAttribute("encoding", "iso8601");
    changeDate.addText(nowStr);//from  w  w  w.  j a v  a 2  s  . c  o m

}