view software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/escidoc/MetadataRecord.java @ 0:408254cf2f1d

Erstellung
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Wed, 24 Nov 2010 17:24:23 +0100
parents
children
line wrap: on
line source

package de.mpg.mpiwg.berlin.mpdl.escidoc;

import java.util.Calendar;
import java.util.Date;

public class MetadataRecord {
  private String docBase;  // e.g. echo or archimedes
  private String identifier;  // identification filename, id number, etc.
  private String language;
  private String creator;  // author
  private String title;
  private String description;
  private String publisher; // publisher with place: e.g. Springer, New York
  private String type; // mime type: e.g. text/xml  // TODO ist eigentlich das Feld "format" --> zus. instnace variable "format" definieren
  private String rights; // e.g. open access
  private Date date; // creation date, modification date, etc.
  private String license;  // e.g. http://echo.mpiwg-berlin.mpg.de/policy/oa_basics/declaration
  private String accessRights;  // e.g. free
  private String mediaType;  // e.g. image or fulltext
  private String eXistIdentifier; // e.g. /echo/la/Benedetti_1585.xml
  private String echoLink; // e.g. echo.mpiwg-berlin.mpg.de?titleID=163127KK
  private String echoDir; // e.g. /permanent/echo/china/songy_tiang_zh_1637
 
  public MetadataRecord() {
    
  }
  
  public MetadataRecord(String identifier, String language, String creator, String title, String description, String publisher, String type, String rights, Date date) {
    this.identifier = identifier;
    this.language = language;
    this.creator = creator;
    this.title = title;
    this.description = description;
    this.publisher = publisher;
    this.type = type;
    this.rights = rights;
    this.date = date;
  }
  
  public String toXmlString() {
    String xmlString = "<metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
    if (identifier != null)
      xmlString += "<dc:identifier>" + identifier + "</dc:identifier>\n";
    if (language != null)
      xmlString += "<dc:language>" + language + "</dc:language>\n";
    if (creator != null)
      xmlString += "<dc:creator>" + creator + "</dc:creator>\n";
    if (title != null)
      xmlString += "<dc:title>" + title + "</dc:title>\n";
    if (description != null)
      xmlString += "<dc:description>" + description + "</dc:description>\n";
    if (publisher != null)
      xmlString += "<dc:publisher>" + publisher + "</dc:publisher>\n";
    if (type != null)
      xmlString += "<dc:type>" + type + "</dc:type>\n";
    if (rights != null)
      xmlString += "<dc:rights>" + rights + "</dc:rights>\n";
    if (date != null)
      xmlString += "<dc:date>" + date + "</dc:date>\n";
    if (license != null)
      xmlString += "<mpiwg:license>" + license + "</mpiwg:license>\n";
    if (accessRights != null)
      xmlString += "<mpiwg:accessRights>" + accessRights + "</mpiwg:accessRights>\n";
    if (mediaType != null)
      xmlString += "<mpiwg:mediaType>" + mediaType + "</mpiwg:mediaType>\n";
    if (eXistIdentifier != null)
      xmlString += "<mpiwg:exist-identifier>" + eXistIdentifier + "</mpiwg:exist-identifier>\n";
    if (echoLink != null)
      xmlString += "<mpiwg:echolink>" + echoLink + "</mpiwg:echolink>\n";
    if (echoDir != null)
      xmlString += "<mpiwg:echodir>" + echoDir + "</mpiwg:echodir>\n";
    xmlString += "</metadata>\n";
    return xmlString;
  }

  public boolean hasEchoDocBase() {
    boolean retValue = false;
    if (docBase != null && docBase.equals("echo"))
      return true;
    return retValue;
  }
  
  public boolean hasArchimedesDocBase() {
    boolean retValue = false;
    if (docBase != null && docBase.equals("archimedes"))
      return true;
    return retValue;
  }
  
  public String getDocBase() {
    return docBase;
  }

  public void setDocBase(String docBase) {
    this.docBase = docBase;
  }

  public String getMediaType() {
    return mediaType;
  }

  public void setMediaType(String mediaType) {
    this.mediaType = mediaType;
  }

  public String getRights() {
    return rights;
  }

  public void setRights(String rights) {
    this.rights = rights;
  }

  public String getLicense() {
    return license;
  }

  public void setLicense(String license) {
    this.license = license;
  }

  public String getAccessRights() {
    return accessRights;
  }

  public void setAccessRights(String accessRights) {
    this.accessRights = accessRights;
  }

  public String getEchoLink() {
    return echoLink;
  }

  public void setEchoLink(String echoLink) {
    this.echoLink = echoLink;
  }

  public String getEchoDir() {
    return echoDir;
  }

  public void setEchoDir(String echoDir) {
    this.echoDir = echoDir;
  }

  public String toString() {
    return toXmlString();
  }

  public String getCreator() {
    return creator;
  }

  public void setCreator(String creator) {
    this.creator = creator;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public Date getDate() {
    return date;
  }

  public void setDate(Date date) {
    this.date = date;
  }

  public String getYear() {
    String year = null;
    if (date != null) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(date);
      int iYear = cal.get(Calendar.YEAR);
      year = "" + iYear;
    }
    return year;
  }
  
  public String getDescription() {
    return description;
  }

  public String getEXistIdentifier() {
    return eXistIdentifier;
  }

  public void setEXistIdentifier(String xistIdentifier) {
    eXistIdentifier = xistIdentifier;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getIdentifier() {
    return identifier;
  }

  public void setIdentifier(String identifier) {
    this.identifier = identifier;
  }

  public String getLanguage() {
    return language;
  }

  public void setLanguage(String language) {
    this.language = language;
  }

  public String getPublisher() {
    return publisher;
  }

  public void setPublisher(String publisher) {
    this.publisher = publisher;
  }

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }

}