Package org.dspace.content

Examples of org.dspace.content.Item


        {
            if (myvalue.getLimitedDataTable() != null)
            {
                for (StatisticDatasBeanRow row : myvalue.getLimitedDataTable())
                {                  
                    Item item = Item.find(context, Integer.parseInt(row.getLabel()));
//                    if (item != null)
                    {
                        labels.addValue(type, row.getLabel(), item);
                    }
                }
View Full Code Here


        {
            return;
        }
        try
        {
            Item myitem = (Item) dso;
            List<String> collectionsList = new Vector<String>();
            List<String> collectionsName = new Vector<String>();
            List<String> collectionsHandle = new Vector<String>();
            List<String> communitiesList = new Vector<String>();
            List<String> communitiesName = new Vector<String>();
            List<String> communitiesHandle = new Vector<String>();
   
            // build list of community ids
            Community[] communities = myitem.getCommunities();
   
            // build list of collection ids
            Collection[] collections = myitem.getCollections();
   
            // now put those into strings
            int i = 0;
   
            for (i = 0; i < communities.length; i++)
View Full Code Here

    private void unlink(Context context, ACrisObject cris, int itemID)
    {
        try
        {
            Item item = Item.find(context, itemID);
            String rpKey = cris.getCrisID();
            ChoiceAuthorityManager cam = ChoiceAuthorityManager.getManager();
            if (metadata == null)
            {
                metadata = cam.getAuthorityMetadataForAuthority(getAuthorityName());
            }
            for (String issued : metadata)
            {
                String[] metadata = issued.split("\\.");
                DCValue[] original = item.getMetadata(issued);
                String schema = metadata[0];
                String element = metadata[1];
                String qualifier = metadata.length > 2 ? metadata[2] : null;
                item.clearMetadata(schema, element, qualifier, Item.ANY);
                for (DCValue md : original)
                {
                    if (rpKey.equals(md.authority))
                    {
                        md.authority = null;
                        md.confidence = Choices.CF_UNSET;
                        // commented the next java line as it is not
                        // anymore necessary. It is already done as part of
                        // "standard" relationpreference management
                        //
                        // cam.notifyReject(item.getID(), schema, element,
                        // qualifier, rpKey);
                    }
                    item.addMetadata(md.schema, md.element, md.qualifier,
                            md.language, md.value, md.authority, md.confidence);

                }
            }
            item.update();
            context.commit();
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.getMessage(), e);
View Full Code Here

    private void link(Context context, ACrisObject cris, int itemID)
    {
        try
        {
            Item item = Item.find(context, itemID);
            String rpKey = cris.getCrisID();
            // the item is not linked with the RP
            ChoiceAuthorityManager cam = ChoiceAuthorityManager.getManager();
            metadata = cam
                    .getAuthorityMetadataForAuthority(getAuthorityName());

            List<String> names = new ArrayList<String>();
            String fieldKey = metadata.get(0);
            String[] split = fieldKey.split("\\.");
            String fschema = split[0];
            String felement = split[1];
            String fqualifier = split.length > 2 ? split[2] : null;
            names.add(cam.getLabel(fschema, felement, fqualifier, rpKey, null));
            List<String> variants = cam.getVariants(fschema, felement, fqualifier,
                    rpKey, null);
            if (variants != null)
            {
                names.addAll(variants);
            }

            for (String issued : metadata)
            {
                String[] metadata = issued.split("\\.");
                DCValue[] original = item.getMetadata(issued);
                String schema = metadata[0];
                String element = metadata[1];
                String qualifier = metadata.length > 2 ? metadata[2] : null;
                item.clearMetadata(schema, element, qualifier, Item.ANY);

                for (DCValue md : original)
                {
                    for (String tempName : names)
                    {
                        if (md.authority == null && md.value.equals(tempName))
                        {
                            md.authority = rpKey;
                            md.confidence = Choices.CF_ACCEPTED;
                        }
                        else if (rpKey.equals(md.authority))
                        {
                            // low confidence value
                            md.confidence = Choices.CF_ACCEPTED;
                        }
                    }
                    item.addMetadata(md.schema, md.element, md.qualifier,
                            md.language, md.value, md.authority, md.confidence);
                }
                item.update();
            }
            context.commit();
        }
        catch (Exception e)
        {
View Full Code Here

                        .append("\n\n");

                for (SolrDocument solrDoc : results)

                {
                    Item item = Item.find(context, (Integer) solrDoc
                            .getFieldValue("search.resourceid"));

                    DCValue[] titles = item.getDC("title", null, Item.ANY);
                    emailText
                            .append("      ")
                            .append(I18nUtil.getMessage(
                                    "org.dspace.eperson.Subscribe.title",
                                    supportedLocale)).append(" ");

                    if (titles.length > 0)
                    {
                        emailText.append(titles[0].value);
                    }
                    else
                    {
                        emailText.append(I18nUtil.getMessage(
                                "org.dspace.eperson.Subscribe.untitled",
                                supportedLocale));
                    }

                    DCValue[] authors = item.getDC("contributor", Item.ANY,
                            Item.ANY);

                    if (authors.length > 0)
                    {
                        emailText
                                .append("\n    ")
                                .append(I18nUtil.getMessage(
                                        "org.dspace.eperson.Subscribe.authors",
                                        supportedLocale)).append(" ")
                                .append(authors[0].value);

                        for (int k = 1; k < authors.length; k++)
                        {
                            emailText.append("\n             ").append(
                                    authors[k].value);
                        }
                    }

                    emailText
                            .append("\n         ")
                            .append(I18nUtil.getMessage(
                                    "org.dspace.eperson.Subscribe.id",
                                    supportedLocale))
                            .append(" ")
                            .append(HandleManager.getCanonicalForm(item
                                    .getHandle())).append("\n\n");
                    context.removeCached(item, item.getID());
                }
            }
        }

        // Send an e-mail if there were any new items
View Full Code Here

        ItemIterator items = Item.findBySubmitter(context, eperson);
        List<MetadataField> mfs = metadataFieldWithAuthorityRP(context);
        int count = 0;
        while (items.hasNext())
        {
            Item item = items.next();
            if (rejected == null || !rejected.contains(item.getID()))
            {
                boolean found = false;
                for (MetadataField mf : mfs)
                {
                    String schema = MetadataSchema.find(context,
                            mf.getSchemaID()).getName();
                    String element = mf.getElement();
                    String qualifier = mf.getQualifier();
                    DCValue[] values = item.getMetadata(schema, element,
                            qualifier, Item.ANY);
                    item.clearMetadata(schema, element, qualifier, Item.ANY);

                    for (DCValue val : values)
                    {
                        if (val.authority == null
                                && val.value != null
                                && StringUtils.containsIgnoreCase(val.value,
                                        eperson.getLastName().trim()))
                        {
                            val.authority = ResearcherPageUtils
                                    .getPersistentIdentifier(rp);
                            val.confidence = Choices.CF_ACCEPTED;
                            found = true;
                        }
                        item.addMetadata(schema, element, qualifier,
                                val.language, val.value, val.authority,
                                val.confidence);
                    }
                }
                if (found)
                {
                    item.update();
                    count++;
                }
            }
        }
        context.restoreAuthSystemState();
View Full Code Here

    public void additionalIndex(Context context, DSpaceObject dso,
            SolrInputDocument document)
    {
        if (!(dso instanceof Item))
            return;
        Item item = (Item) dso;
        try
        {
            Bundle[] bb = item.getBundles();
            for (Bundle b : bb)
            {

                List<String> bitstreams = new ArrayList<String>();
                for (Bitstream bitstream : b.getBitstreams())
View Full Code Here

    public void additionalIndex(Context context, DSpaceObject dso,
            SolrInputDocument document)
    {
        if (!(dso instanceof Item))
            return;
        Item item = (Item) dso;
        int itemID = item.getID();
        List<RelationPreference> preferences = applicationService
                .findRelationsPreferencesForItemID(itemID);
        if (preferences != null)
        {
            for (RelationPreference rp : preferences)
View Full Code Here

    {
        // get button user pressed
        String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON);

        // get reference to item
        Item item = subInfo.getSubmissionItem().getItem();

        // -----------------------------------
        // Step #0: Upload new files (if any)
        // -----------------------------------
        String contentType = request.getContentType();

        // if multipart form, then we are uploading a file
        if ((contentType != null)
                && (contentType.indexOf("multipart/form-data") != -1))
        {
            // This is a multipart request, so it's a file upload
            // (return any status messages or errors reported)
            int status = processUploadFile(context, request, response, subInfo);

            // if error occurred, return immediately
            if (status != STATUS_COMPLETE)
                return status;
        }
           
        // if user pressed jump-to button in process bar,
        // return success (so that jump will occur)
        if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX))
        {
            // check if a file is required to be uploaded
            if (fileRequired && !item.hasUploadedFiles())
            {
                return STATUS_NO_FILES_ERROR;
            }
            else
            {
                return STATUS_COMPLETE;
            }
        }

        // ---------------------------------------------
        // Step #1: Check if this was just a request to
        // edit file information.
        // (or canceled editing information)
        // ---------------------------------------------
        // check if we're already editing a specific bitstream
        if (request.getParameter("bitstream_id") != null)
        {
            if (buttonPressed.equals(CANCEL_EDIT_BUTTON))
            {
                // canceled an edit bitstream request
                subInfo.setBitstream(null);

                // this flag will just return us to the normal upload screen
                return STATUS_EDIT_COMPLETE;
            }
            else
            {
                // load info for bitstream we are editing
                Bitstream b = Bitstream.find(context, Integer.parseInt(request
                        .getParameter("bitstream_id")));

                // save bitstream to submission info
                subInfo.setBitstream(b);
            }
        }
        else if (buttonPressed.startsWith("submit_edit_"))
        {
            // get ID of bitstream that was requested for editing
            String bitstreamID = buttonPressed.substring("submit_edit_"
                    .length());

            Bitstream b = Bitstream
                    .find(context, Integer.parseInt(bitstreamID));

            // save bitstream to submission info
            subInfo.setBitstream(b);

            // return appropriate status flag to say we are now editing the
            // bitstream
            return STATUS_EDIT_BITSTREAM;
        }

        // ---------------------------------------------
        // Step #2: Process any remove file request(s)
        // ---------------------------------------------
        // Remove-selected requests come from Manakin
        if (buttonPressed.equalsIgnoreCase("submit_remove_selected"))
        {
            // this is a remove multiple request!

            if (request.getParameter("remove") != null)
            {
                // get all files to be removed
                String[] removeIDs = request.getParameterValues("remove");

                // remove each file in the list
                for (int i = 0; i < removeIDs.length; i++)
                {
                    int id = Integer.parseInt(removeIDs[i]);

                    int status = processRemoveFile(context, item, id);

                    // if error occurred, return immediately
                    if (status != STATUS_COMPLETE)
                        return status;
                }

                // remove current bitstream from Submission Info
                subInfo.setBitstream(null);
            }
        }
        else if (buttonPressed.startsWith("submit_remove_"))
        {
            // A single file "remove" button must have been pressed

            int id = Integer.parseInt(buttonPressed.substring(14));
            int status = processRemoveFile(context, item, id);

            // if error occurred, return immediately
            if (status != STATUS_COMPLETE)
                return status;

            // remove current bitstream from Submission Info
            subInfo.setBitstream(null);
        }

        // -------------------------------------------------
        // Step #3: Check for a change in file description
        // -------------------------------------------------
        String fileDescription = request.getParameter("description");

        if (fileDescription != null && fileDescription.length() > 0)
        {
            // save this file description
            int status = processSaveFileDescription(context, request, response,
                    subInfo);

            // if error occurred, return immediately
            if (status != STATUS_COMPLETE)
                return status;
        }

        // ------------------------------------------
        // Step #4: Check for a file format change
        // (if user had to manually specify format)
        // ------------------------------------------
        int formatTypeID = Util.getIntParameter(request, "format");
        String formatDesc = request.getParameter("format_description");

        // if a format id or description was found, then save this format!
        if (formatTypeID >= 0
                || (formatDesc != null && formatDesc.length() > 0))
        {
            // save this specified format
            int status = processSaveFileFormat(context, request, response,
                    subInfo);

            // if error occurred, return immediately
            if (status != STATUS_COMPLETE)
                return status;
        }

        // ---------------------------------------------------
        // Step #5: Check if primary bitstream has changed
        // -------------------------------------------------
        if (request.getParameter("primary_bitstream_id") != null)
        {
            Bundle[] bundles = item.getBundles("ORIGINAL");
            if (bundles.length > 0)
            {
              bundles[0].setPrimaryBitstreamID(new Integer(request
                    .getParameter("primary_bitstream_id")).intValue());
              bundles[0].update();
            }
        }

        // ---------------------------------------------------
        // Step #6: Determine if there is an error because no
        // files have been uploaded.
        // ---------------------------------------------------
        //check if a file is required to be uploaded
        if (fileRequired && !item.hasUploadedFiles())
        {
            return STATUS_NO_FILES_ERROR;
        }

        // commit all changes to database
View Full Code Here

                    return STATUS_UPLOAD_ERROR;
               
                if (subInfo != null)
                {
                    // Create the bitstream
                    Item item = subInfo.getSubmissionItem().getItem();
       
                    // do we already have a bundle?
                    Bundle[] bundles = item.getBundles("ORIGINAL");
       
                    if (bundles.length < 1)
                    {
                        // set bundle's name to ORIGINAL
                        b = item.createSingleBitstream(fileInputStream, "ORIGINAL");
                    }
                    else
                    {
                        // we have a bundle already, just add bitstream
                        b = bundles[0].createBitstream(fileInputStream);
                    }
       
                    // Strip all but the last filename. It would be nice
                    // to know which OS the file came from.
                    String noPath = filePath;
       
                    while (noPath.indexOf('/') > -1)
                    {
                        noPath = noPath.substring(noPath.indexOf('/') + 1);
                    }
       
                    while (noPath.indexOf('\\') > -1)
                    {
                        noPath = noPath.substring(noPath.indexOf('\\') + 1);
                    }
       
                    b.setName(noPath);
                    b.setSource(filePath);
                    b.setDescription(fileDescription);
       
                    // Identify the format
                    bf = FormatIdentifier.guessFormat(context, b);
                    b.setFormat(bf);
       
                    // Update to DB
                    b.update();
                    item.update();
       
                    if (bf == null || !bf.isInternal())
                    {
                        fileOK = true;
                    }
                    else
                    {
                        log.warn("Attempt to upload file format marked as internal system use only");
                       
                        // remove bitstream from bundle..
                        // delete bundle if it's now empty
                        Bundle[] bnd = b.getBundles();

                        bnd[0].removeBitstream(b);

                        Bitstream[] bitstreams = bnd[0].getBitstreams();

                        // remove bundle if it's now empty
                        if (bitstreams.length < 1)
                        {
                            item.removeBundle(bnd[0]);
                            item.update();
                        }

                        subInfo.setBitstream(null);
                    }
                }// if subInfo not null
View Full Code Here

TOP

Related Classes of org.dspace.content.Item

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.