Package org.dspace.app.xmlui.wing

Examples of org.dspace.app.xmlui.wing.AttributeMap


     */
    public void toSAX(ContentHandler contentHandler,
            LexicalHandler lexicalHandler, NamespaceSupport namespaces)
            throws SAXException
    {
        AttributeMap attributes = new AttributeMap();

        // Determine if there are any operations
        String operations = null;
        if (addOperation )
        {
            if (operations == null)
                operations = OPERATION_ADD;
            else
                operations += " " + OPERATION_ADD;
        }
        if (addOperation)
        {
            if (operations == null)
                operations = OPERATION_DELETE;
            else
                operations += " " + OPERATION_DELETE;
        }
        if (operations != null)
            attributes.put(A_OPERATIONS, operations);

       
       
        if (this.returnValue != null)
        {
            attributes.put(A_RETURN_VALUE, this.returnValue);
        }

        if (this.size > -1)
        {
            attributes.put(A_SIZE, this.size);
        }

        if (this.maxlength > -1)
        {
            attributes.put(A_MAX_LENGTH, this.maxlength);
        }

        if (this.multiple == true)
        {
            attributes.put(A_MULTIPLE, this.multiple);
        }

        if (this.rows > -1)
        {
            attributes.put(A_ROWS, this.rows);
        }

        if (this.cols > -1)
        {
            attributes.put(A_COLS, this.cols);
        }

        if (this.authority)
            attributes.put(A_AUTHORITY_CONTROLLED, this.authority);
        if (this.authority_required)
            attributes.put(A_AUTHORITY_REQUIRED, this.authority_required);
        if (this.choices != null)
            attributes.put(A_CHOICES, this.choices);
        if (this.presentation != null)
            attributes.put(A_CHOICES_PRESENTATION, this.presentation);
        if (this.choicesClosed)
            attributes.put(A_CHOICES_CLOSED, true);

        startElement(contentHandler, namespaces, E_PARAMS, attributes);
        endElement(contentHandler, namespaces, E_PARAMS);
    }
View Full Code Here


            startElement(contentHandler, namespaces, E_REPOSITORY_META, null);
   
      for (String identifier : repositories.keySet())
      {
        // add the repository XML
        AttributeMap attributes = new AttributeMap();
        attributes.put(A_REPOSITORY_ID, identifier);
        attributes.put(A_REPOSITORY_URL, repositories.get(identifier));
       
        startElement(contentHandler,namespaces,E_REPOSITORY,attributes);
        endElement(contentHandler,namespaces,E_REPOSITORY);
      }
      
View Full Code Here

    public void toSAX(ContentHandler contentHandler,
            LexicalHandler lexicalHandler, NamespaceSupport namespaces)
            throws SAXException
    {
        AttributeMap attributes = new AttributeMap();
        attributes.put(A_TYPE, this.type);

        if (this.option != null)
            attributes.put(A_OPTION, this.option);
        if (this.checked)
            attributes.put(A_CHECKED, this.checked);
        if (this.type.equals(TYPE_AUTHORITY))
            attributes.put(A_CONFIDENCE, this.confidence);
       
        startElement(contentHandler, namespaces, E_VALUE, attributes);
        super.toSAX(contentHandler, lexicalHandler, namespaces);
        endElement(contentHandler, namespaces, E_VALUE);
    }
View Full Code Here

     *            to determine the correct prefix for a given namespace URI.
     */
    public void toSAX(ContentHandler contentHandler, LexicalHandler lexicalHandler,
            NamespaceSupport namespaces) throws SAXException
    {
        AttributeMap attributes = new AttributeMap();
        attributes.put(A_REPOSITORY_ID, this.repository);
        attributes.put(A_URL, this.url);
        if (type != null)
          attributes.put(A_TYPE, type);
       
        startElement(contentHandler, namespaces, E_REFERENCE, attributes);

        for (AbstractWingElement content : contents)
        {
View Full Code Here

     */
    public void toSAX(ContentHandler contentHandler,
            LexicalHandler lexicalHandler, NamespaceSupport namespaces)
            throws SAXException
    {
        AttributeMap attributes = new AttributeMap();

        attributes.put(A_NAME, this.name);
        attributes.put(A_ID, this.context.generateID(E_FIELD, this.name));
        attributes.put(A_FIELD_TYPE, this.type);
        if (this.disabled)
            attributes.put(A_DISABLED, this.disabled);
        if (this.required)
            attributes.put(A_REQUIRED, this.required);
        if (this.rend != null)
            attributes.put(A_RENDER, this.rend);

        startElement(contentHandler, namespaces, E_FIELD, attributes);

        if (params != null)
            params.toSAX(contentHandler, lexicalHandler, namespaces);
View Full Code Here

     *    </xmlDate>
     *  </mdWrap>
     * </dmdSec
     */
    protected void renderDescriptiveSection() throws WingException, SAXException, CrosswalkException, IOException, SQLException {
        AttributeMap attributes;
        String groupID = getGenericID("group_dmd_");
        dmdSecIDS = new StringBuffer();

        // Add DIM descriptive metadata if it was requested or if no metadata types
        // were specified. Further more since this is the default type we also use a
        // faster rendering method that the crosswalk API.
        if (dmdTypes.size() == 0 || dmdTypes.contains("DIM")) {
            // Metadata element's ID
            String dmdID = getGenericID("dmd_");
            // Keep track of all descriptive sections
            dmdSecIDS.append("" + dmdID);

            ////////////////////////////////
            // Start a metadata wrapper
            attributes = new AttributeMap();
            attributes.put("ID", dmdID);
            attributes.put("GROUPID", groupID);
            startElement(METS, "dmdSec", attributes);

            ////////////////////////////////
            // Start a metadata wrapper
            attributes = new AttributeMap();
            attributes.put("MDTYPE", "OTHER");
            attributes.put("OTHERMDTYPE", "DIM");
            startElement(METS, "mdWrap", attributes);

            // ////////////////////////////////
            // Start the xml data
            startElement(METS, "xmlData");


            // ///////////////////////////////
            // Start the DIM element
            attributes = new AttributeMap();
            attributes.put("dspaceType", Constants.typeText[item.getType()]);
            if (item.isWithdrawn()) {
                attributes.put("withdrawn", "y");
            }
            startElement(DIM, "dim", attributes);

            DCValue[] dcvs = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
            for (DCValue dcv : dcvs) {
                if (!MetadataExposure.isHidden(context, dcv.schema, dcv.element, dcv.qualifier)) {
                    // ///////////////////////////////
                    // Field element for each metadata field.
                    attributes = new AttributeMap();
                    attributes.put("mdschema", dcv.schema);
                    attributes.put("element", dcv.element);
                    if (dcv.qualifier != null) {
                        attributes.put("qualifier", dcv.qualifier);
                    }
                    if (dcv.language != null) {
                        attributes.put("language", dcv.language);
                    }
                    if (dcv.authority != null || dcv.confidence != Choices.CF_UNSET) {
                        attributes.put("authority", dcv.authority);
                        attributes.put("confidence", Choices.getConfidenceText(dcv.confidence));
                    }
                    startElement(DIM, "field", attributes);
                    sendCharacters(dcv.value);
                    endElement(DIM, "field");
                }
            }

            // ///////////////////////////////
            // End the DIM element
            endElement(DIM, "dim");

            // ////////////////////////////////
            // End elements
            endElement(METS, "xmlData");
            endElement(METS, "mdWrap");
            endElement(METS, "dmdSec");

        }


        // Add any extra crosswalks that may configured.
        for (String dmdType : dmdTypes) {
            // If DIM was requested then it was generated above without using
            // the crosswalk API. So we can skip this one.
            if ("DIM".equals(dmdType)) {
                continue;
            }

            DisseminationCrosswalk crosswalk = getDisseminationCrosswalk(dmdType);

            if (crosswalk == null) {
                continue;
            }

            String dmdID = getGenericID("dmd_");
            // Add our id to the list.
            dmdSecIDS.append(" " + dmdID);

            ////////////////////////////////
            // Start a metadata wrapper
            attributes = new AttributeMap();
            attributes.put("ID", dmdID);
            attributes.put("GROUPID", groupID);
            startElement(METS, "dmdSec", attributes);

            ////////////////////////////////
            // Start a metadata wrapper
            attributes = new AttributeMap();
            if (isDefinedMETStype(dmdType)) {
                attributes.put("MDTYPE", dmdType);
            } else {
                attributes.put("MDTYPE", "OTHER");
                attributes.put("OTHERMDTYPE", dmdType);
            }
            startElement(METS, "mdWrap", attributes);

            // ////////////////////////////////
            // Start the xml data
            startElement(METS, "xmlData");


            // ///////////////////////////////
            // Send the actual XML content
            try {
                Element dissemination = crosswalk.disseminateElement(item);

                SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
                // Allow the basics for XML
                filter.allowElements().allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();

                SAXOutputter outputter = new SAXOutputter();
                outputter.setContentHandler(filter);
                outputter.setLexicalHandler(filter);
                outputter.output(dissemination);
            } catch (JDOMException jdome) {
                throw new WingException(jdome);
            } catch (AuthorizeException ae) {
                // just ignore the authorize exception and continue on with
                //out parsing the xml document.
            }


            // ////////////////////////////////
            // End elements
            endElement(METS, "xmlData");
            endElement(METS, "mdWrap");
            endElement(METS, "dmdSec");
        }


        // Check to see if there is an in-line MODS document
        // stored as a bitstream. If there is then we should also
        // include these metadata in our METS document. However
        // we don't really know what the document describes, so we
        // but it in it's own dmd group.

        Boolean include = ConfigurationManager.getBooleanProperty("xmlui.bitstream.mods");
        if (include && dmdTypes.contains("MODS")) {
            // Generate a second group id for any extra metadata added.
            String groupID2 = getGenericID("group_dmd_");

            Bundle[] bundles = item.getBundles("METADATA");
            for (Bundle bundle : bundles) {
                Bitstream bitstream = bundle.getBitstreamByName("MODS.xml");

                if (bitstream == null) {
                    continue;
                }


                String dmdID = getGenericID("dmd_");


                ////////////////////////////////
                // Start a metadata wrapper
                attributes = new AttributeMap();
                attributes.put("ID", dmdID);
                attributes.put("GROUPID", groupID2);
                startElement(METS, "dmdSec", attributes);

                ////////////////////////////////
                // Start a metadata wrapper
                attributes = new AttributeMap();
                attributes.put("MDTYPE", "MODS");
                startElement(METS, "mdWrap", attributes);

                // ////////////////////////////////
                // Start the xml data
                startElement(METS, "xmlData");
View Full Code Here

     *    </xmlDate>
     *  </mdWrap>
     * </amdSec>
     */
    protected void renderAdministrativeSection() throws WingException, SAXException, CrosswalkException, IOException, SQLException {
        AttributeMap attributes;
        String groupID;

        //Only create an <amdSec>, if we have amdTypes (or sub-sections) specified...
        // (this keeps our METS file small, by default, and hides all our admin metadata)
        if (amdTypes.size() > 0) {
            ////////////////////////////////
            // Start an administrative wrapper

            // Administrative element's ID
            String amdID = getGenericID("amd_");
            attributes = new AttributeMap();
            attributes.put("ID", amdID);
            startElement(METS, "amdSec", attributes);

            groupID = getGenericID("group_amd_");
            attributes.put("GROUPID", groupID);
        }

        // For each administrative metadata section specified
        for (String amdSecName : amdTypes.keySet()) {
            //get a list of metadata crosswalks which will be used to build
View Full Code Here

    protected void renderAmdSubSection(String amdSecName, String mdType, DisseminationCrosswalk crosswalk, DSpaceObject dso)
            throws WingException, SAXException, CrosswalkException, IOException, SQLException {
        /////////////////////////////////
        // Start administrative metadata section wrapper
        String amdSecID = getAmdSecID(amdSecName, mdType, dso);
        AttributeMap attributes = new AttributeMap();
        attributes.put("ID", amdSecID);
        startElement(METS, amdSecName, attributes);

        //If this is a bitstream
        if (dso.getType() == Constants.BITSTREAM) {
            // Add this to our list of each file's administrative section IDs
            String fileID = getFileID((Bitstream) dso);
            if (fileAmdSecIDs.containsKey(fileID)) {
                fileAmdSecIDs.get(fileID).append(" " + amdSecID);
            } else {
                fileAmdSecIDs.put(fileID, new StringBuffer(amdSecID));
            }
        }//else if an Item
        else if (dso.getType() == Constants.ITEM) {
            //Add this to our list of item's administrative section IDs
            if (amdSecIDS == null) {
                amdSecIDS = new StringBuffer(amdSecID);
            } else {
                amdSecIDS.append(" " + amdSecID);
            }
        }

        ////////////////////////////////
        // Start a metadata wrapper
        attributes = new AttributeMap();
        if (isDefinedMETStype(mdType)) {
            attributes.put("MDTYPE", mdType);
        } else {
            attributes.put("MDTYPE", "OTHER");
            attributes.put("OTHERMDTYPE", mdType);
        }
        startElement(METS, "mdWrap", attributes);

        //////////////////////////////////
        // Start the xml data
View Full Code Here

     *     </file>
     *   </fileGrp>
     * </fileSec>
     */
    protected void renderFileSection() throws SQLException, SAXException {
        AttributeMap attributes;

        // //////////////////////
        // Start a new file section
        startElement(METS, "fileSec");

        // Check if the user is requested a specific bundle or
        // the all bundles.
        List<Bundle> bundles = findEnabledBundles();

        // Suppress license?
        Boolean showLicense = ConfigurationManager.getBooleanProperty("webui.licence_bundle.show");

        // Loop over all requested bundles
        for (Bundle bundle : bundles) {

            // Use the bitstream's name as the use parameter unless we
            // are the original bundle. In this case rename it to
            // content.
            String use = bundle.getName();
            boolean isContentBundle = false; // remember the content bundle.
            boolean isDerivedBundle = false;
            if ("ORIGINAL".equals(use)) {
                use = "CONTENT";
                isContentBundle = true;
            }
            if ("TEXT".equals(bundle.getName()) || "THUMBNAIL".equals(bundle.getName())) {
                isDerivedBundle = true;
            }
            if ("LICENSE".equals(bundle.getName()) && !showLicense) {
                continue;
            }

            // ///////////////////
            // Start bundle's file group
            attributes = new AttributeMap();
            attributes.put("USE", use);
            startElement(METS, "fileGrp", attributes);

            for (Bitstream bitstream : bundle.getBitstreams()) {
                // //////////////////////////////
                // Determine the file's IDs
View Full Code Here

     *     ... a div for each content bitstream.
     *   </div>
     * </structMap>
     */
    protected void renderStructureMap() throws SQLException, SAXException {
        AttributeMap attributes;

        // ///////////////////////
        // Start a new structure map
        attributes = new AttributeMap();
        attributes.put("TYPE", "LOGICAL");
        attributes.put("LABEL", "DSpace");
        startElement(METS, "structMap", attributes);

        // ////////////////////////////////
        // Start the special first division
        attributes = new AttributeMap();
        attributes.put("TYPE", "DSpace Item");
        // add references to the Descriptive metadata
        if (dmdSecIDS != null) {
            attributes.put("DMDID", dmdSecIDS.toString());
        }
        // add references to the Administrative metadata
        if (amdSecIDS != null) {
            attributes.put("AMDID", amdSecIDS.toString());
        }
        startElement(METS, "div", attributes);

        // add a fptr pointer to the primary bitstream.
        if (primaryBitstream != null) {
            // ////////////////////////////////
            // Start & end a refrence to the primary bistream.
            attributes = new AttributeMap();
            String fileID = getFileID(primaryBitstream);
            attributes.put("FILEID", fileID);

            startElement(METS, "fptr", attributes);
            endElement(METS, "fptr");
        }

        for (Bitstream bitstream : contentBitstreams) {
            // ////////////////////////////////////
            // Start a div for each publicaly viewable bitstream
            attributes = new AttributeMap();
            attributes.put("ID", getGenericID("div_"));
            attributes.put("TYPE", "DSpace Content Bitstream");
            startElement(METS, "div", attributes);

            // ////////////////////////////////
            // Start a the actualy pointer to the bitstream
            attributes = new AttributeMap();
            String fileID = getFileID(bitstream);
            attributes.put("FILEID", fileID);
            String fileInternalID = getFileInternalID(bitstream);
            attributes.put("FILEINTERNALID", fileInternalID);

            startElement(METS, "fptr", attributes);
            endElement(METS, "fptr");

            // ///////////////////////////////
View Full Code Here

TOP

Related Classes of org.dspace.app.xmlui.wing.AttributeMap

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.