Examples of DCFields


Examples of org.fcrepo.server.utilities.DCFields

            } else {
                dbRowValues[6] = "" + dcmd.DSCreateDT.getTime();
            }
            if (dcmd != null && m_indexDCFields) {
                InputStream in = dcmd.getContentStream();
                DCFields dc = new DCFields(in);

                dbRowValues[7] = getDbValue(dc.titles());
                dbRowValues[8] = getDbValue(dc.creators());
                dbRowValues[9] = getDbValue(dc.subjects());
                dbRowValues[10] = getDbValue(dc.descriptions());
                dbRowValues[11] = getDbValue(dc.publishers());
                dbRowValues[12] = getDbValue(dc.contributors());
                dbRowValues[13] = getDbValue(dc.dates());

                // delete any dc.dates that survive from earlier versions
                st = conn.prepareStatement("DELETE FROM dcDates WHERE pid=?");
                st.setString(1, pid);
                st.executeUpdate();

                // get any dc.dates strings that are formed such that they
                // can be treated as a timestamp
                List<Date> wellFormedDates = null;
                for (int i = 0; i < dc.dates().size(); i++) {
                    if (i == 0) {
                        wellFormedDates = new ArrayList<Date>();
                    }
                    Date p = DateUtility.parseDateLoose(dc.dates().get(i).getValue());
                    if (p != null) {
                        wellFormedDates.add(p);
                    }
                }
                if (wellFormedDates != null && wellFormedDates.size() > 0) {
                    // found at least one valid date, so add them.
                    for (int i = 0; i < wellFormedDates.size(); i++) {
                        Date dt = wellFormedDates.get(i);
                        String query =
                          "INSERT INTO dcDates (pid, dcDate) values (?, ?)";
                        st = conn.prepareStatement(query);
                        st.setString(1, pid);
                        st.setLong(2, dt.getTime());
                        st.executeUpdate();
                    }
                }
                dbRowValues[14] = getDbValue(dc.types());
                dbRowValues[15] = getDbValue(dc.formats());
                dbRowValues[16] = getDbValue(dc.identifiers());
                dbRowValues[17] = getDbValue(dc.sources());
                dbRowValues[18] = getDbValue(dc.languages());
                dbRowValues[19] = getDbValue(dc.relations());
                dbRowValues[20] = getDbValue(dc.coverages());
                dbRowValues[21] = getDbValue(dc.rights());
                logger.debug("Formulating SQL and inserting/updating WITH DC...");
                SQLUtility.replaceInto(conn,
                                       "doFields",
                                       DB_COLUMN_NAMES,
                                       dbRowValues,
View Full Code Here

Examples of org.fcrepo.server.utilities.DCFields

    }

    public String getOAIDublinCore(Datastream dublinCore)
            throws ServerException {
        DCFields dc;
        if (dublinCore == null) {
            dc = new DCFields();
        } else {
            InputStream in = dublinCore.getContentStream();
            dc = new DCFields(in);
        }
        return dc.getAsXML();
    }
View Full Code Here

Examples of org.fcrepo.server.utilities.DCFields

     * in the DC datastream.
     */
    private void addDCTriples(Datastream ds,
                              URIReference objURI,
                              Set<Triple> set) throws Exception {
        DCFields dc = new DCFields(ds.getContentStream());
        Map<RDFName, List<DCField>> map = dc.getMap();
        for (RDFName predicate : map.keySet()) {
            for (DCField dcField : map.get(predicate)) {
                String lang = dcField.getLang();
                if (lang == null) {
                    add(objURI, predicate, dcField.getValue(), set);
View Full Code Here

Examples of org.fcrepo.server.utilities.DCFields

                checksumType = orig.DSChecksumType;
            } else {
                checksumType = Datastream.validateChecksumType(checksumType);
            }
            if (dsContent != null && "DC".equals(datastreamId)){
                DCFields audited = new DCFields(dsContent);
                try {
                    dsContent = new ByteArrayInputStream(audited.getAsXML(pid).getBytes("UTF-8"));
                } catch (UnsupportedEncodingException uee) {
                    // safely ignore... we know UTF-8 works
                }
            }
View Full Code Here

Examples of org.fcrepo.server.utilities.DCFields

     */
    private static void populateDC(Context ctx, DigitalObject obj, DOWriter w,
            Date nowUTC) throws IOException, ServerException {
        logger.debug("Adding/Checking default DC datastream");
        Datastream dc = w.GetDatastream("DC", null);
        DCFields dcf;
        XMLDatastreamProcessor dcxml = null;

        if (dc == null) {
            dcxml = new XMLDatastreamProcessor("DC");
            dc = dcxml.getDatastream();
            //dc.DSMDClass=DatastreamXMLMetadata.DESCRIPTIVE;
            dc.DatastreamID = "DC";
            dc.DSVersionID = "DC1.0";
            //dc.DSControlGrp = "X"; set by XMLDatastreamProcessor instead
            dc.DSCreateDT = nowUTC;
            dc.DSLabel = "Dublin Core Record for this object";
            dc.DSMIME = "text/xml";
            dc.DSFormatURI = OAI_DC2_0.uri;
            dc.DSSize = 0;
            dc.DSState = "A";
            dc.DSVersionable = true;
            dcf = new DCFields();
            if (obj.getLabel() != null && !obj.getLabel().equals("")) {
                dcf.titles().add(new DCField(obj.getLabel()));
            }
            w.addDatastream(dc, dc.DSVersionable);
        } else {
            dcxml = new XMLDatastreamProcessor(dc);
            // note: context may be required to get through authz as content
            // could be filesystem file (or URL)
            dcf =
                    new DCFields(new ByteArrayInputStream(dcxml
                            .getXMLContent(ctx)));
        }
        // set the value of the dc datastream according to what's in the
        // DCFields object
        // ensure one of the dc:identifiers is the pid
        try {
            dcxml.setXMLContent(dcf.getAsXML(obj.getPid()).getBytes("UTF-8"));
        } catch (UnsupportedEncodingException uee) {
            // safely ignore... we know UTF-8 works
        }
    }
View Full Code Here

Examples of org.fcrepo.server.utilities.DCFields

        engine.setNamespaceContext(ctx);
    }

    @Test
    public void testDCFieldsInputStream() throws Exception {
        DCFields dc;
        Document dcXML;

        dc = new DCFields(new ByteArrayInputStream(dcWithXmlLang.getBytes("UTF-8")));
        dcXML = XMLUnit.buildControlDocument(dc.getAsXML());
        assertEquals("Time interval",
                     engine.evaluate("//dc:subject[@xml:lang='en']", dcXML));
        assertEquals("Tidsinterval",
                     engine.evaluate("//dc:subject[@xml:lang='da']", dcXML));

        dc = new DCFields();
        dcXML = XMLUnit.buildControlDocument(dc.getAsXML());
        assertEquals("Expected empty element",
                     "",
                     engine.evaluate("//oai_dc:dc", dcXML).trim());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.