Package org.dspace.content

Examples of org.dspace.content.Metadatum


  /**
   * Compare names of two metadata elements so that they may be sorted.
   */
  static class DCValueComparator implements Comparator, Serializable {
    public int compare(Object arg0, Object arg1) {
      final Metadatum o1 = (Metadatum)arg0;
      final Metadatum o2 = (Metadatum)arg1;
      final String s1 = o1.schema + o1.element + (o1.qualifier==null?"":("." + o1.qualifier));
      final  String s2 = o2.schema + o2.element + (o2.qualifier==null?"":("." + o2.qualifier));
      return s1.compareTo(s2);
    }
View Full Code Here


            }

            while (tri.hasNext())
            {
                TableRow tr = tri.next();
                Metadatum dcv = new Metadatum();
                dcv.schema = schema;
                dcv.element = tr.getStringColumn("element");
                dcv.qualifier = tr.getStringColumn("qualifier");
                dcv.language = tr.getStringColumn("text_lang");
                dcv.value = tr.getStringColumn("text_value");
View Full Code Here

                Integer key = Integer.valueOf(so.getNumber());
                String metadata = so.getMetadata();

                // If we've already used the metadata for this Item
                // it will be cached in the map
                Metadatum value = null;

                if (itemMDMap != null)
                {
                    value = (Metadatum) itemMDMap.get(metadata);
                }
View Full Code Here

    if (field == null || "".equals(field))
    {
      throw new DSpaceSwordException("No configuration, or configuration is invalid for: sword.updated.field");
    }

    Metadatum dc = this.configToDC(field, null);
    item.clearMetadata(dc.schema, dc.element, dc.qualifier, Item.ANY);
    DCDate date = new DCDate(new Date());
    item.addMetadata(dc.schema, dc.element, dc.qualifier, null, date.toString());

    verboseDescription.append("Updated date added to response from item metadata where available");
View Full Code Here

    if (field == null || "".equals(field))
    {
      throw new DSpaceSwordException("No configuration, or configuration is invalid for: sword.slug.field");
    }

    Metadatum dc = this.configToDC(field, null);
    item.clearMetadata(dc.schema, dc.element, dc.qualifier, Item.ANY);
    item.addMetadata(dc.schema, dc.element, dc.qualifier, null, slugVal);

    verboseDescription.append("Slug value set in response where available");
  }
View Full Code Here

   * @param config
   * @param def
   */
  protected Metadatum configToDC(String config, String def)
  {
    Metadatum dcv = new Metadatum();
    dcv.schema = def;
    dcv.element= def;
    dcv.qualifier = def;

    StringTokenizer stz = new StringTokenizer(config, ".");
View Full Code Here

            }

            while (tri.hasNext())
            {
                TableRow tr = tri.next();
                Metadatum dcv = new Metadatum();
                dcv.schema = schema;
                dcv.element = tr.getStringColumn("element");
                dcv.qualifier = tr.getStringColumn("qualifier");
                dcv.language = tr.getStringColumn("text_lang");
                dcv.value = tr.getStringColumn("text_value");
View Full Code Here

        /**
         * Compare two metadata element's name so that they may be sorted.
         */
        static class DCValueComparator implements Comparator, Serializable {
                public int compare(Object arg0, Object arg1) {
                        final Metadatum o1 = (Metadatum)arg0;
                        final Metadatum o2 = (Metadatum)arg1;
                        final String s1 = o1.schema + o1.element + (o1.qualifier==null?"":("." + o1.qualifier));
                        final  String s2 = o2.schema + o2.element + (o2.qualifier==null?"":("." + o2.qualifier));
                        return s1.compareTo(s2);
                }
View Full Code Here

                    if (isDate)
                    {
                        df = df.replaceAll("\\(date\\)", "");
                    }
            
                    Metadatum dcv[] = item.getMetadataByMetadataString(df);
                    if (dcv.length > 0)
                    {
                        String fieldLabel = labels.get(MSG_METADATA + df);
                        if (fieldLabel != null && fieldLabel.length()>0)
                        {
                            db.append(fieldLabel).append(": ");
                        }
                        boolean first = true;
                        for (Metadatum v : dcv)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                db.append("; ");
                            }
                            db.append(isDate ? new DCDate(v.value).toString() : v.value);
                        }
                        db.append("\n");
                    }
                }
                if (db.length() > 0)
                {
                    SyndContent desc = new SyndContentImpl();
                    desc.setType("text/plain");
                    desc.setValue(db.toString());
                    entry.setDescription(desc);
                }

                // This gets the authors into an ATOM feed
                Metadatum authors[] = item.getMetadataByMetadataString(authorField);
                if (authors.length > 0)
                {
                    List<SyndPerson> creators = new ArrayList<SyndPerson>();
                    for (Metadatum author : authors)
                    {
                        SyndPerson sp = new SyndPersonImpl();
                        sp.setName(author.value);
                        creators.add(sp);
                    }
                    entry.setAuthors(creators);
                }

                // only add DC module if any DC fields are configured
                if (dcCreatorField != null || dcDateField != null ||
                    dcDescriptionField != null)
                {
                    DCModule dc = new DCModuleImpl();
                    if (dcCreatorField != null)
                    {
                        Metadatum dcAuthors[] = item.getMetadataByMetadataString(dcCreatorField);
                        if (dcAuthors.length > 0)
                        {
                            List<String> creators = new ArrayList<String>();
                            for (Metadatum author : dcAuthors)
                            {
                                creators.add(author.value);
                            }
                            dc.setCreators(creators);
                        }
                    }
                    if (dcDateField != null && !hasDate)
                    {
                        Metadatum v[] = item.getMetadataByMetadataString(dcDateField);
                        if (v.length > 0)
                        {
                            dc.setDate((new DCDate(v[0].value)).toDate());
                        }
                    }
                    if (dcDescriptionField != null)
                    {
                        Metadatum v[] = item.getMetadataByMetadataString(dcDescriptionField);
                        if (v.length > 0)
                        {
                            StringBuffer descs = new StringBuffer();
                            for (Metadatum d : v)
                            {
View Full Code Here

    }

    // spoonful of syntactic sugar when we only need first value
    private String getOneDC(Item item, String field)
    {
        Metadatum dcv[] = item.getMetadataByMetadataString(field);
        return (dcv.length > 0) ? dcv[0].value : null;
    }
View Full Code Here

TOP

Related Classes of org.dspace.content.Metadatum

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.