Package org.dspace.app.cris.model

Examples of org.dspace.app.cris.model.Project


        log.info("Start import " + new Date());
        // foreach researcher element in xml
        for (int i = 0; i < grantxml.size(); i++)
        {
            log.info("Number " + i + " of " + grantxml.size());
            Project grant = null;
            try
            {
                Element node = grantxml.get(i);

                // check if staffNo and rpid exists as attribute
                // String nodeId = (String) xpath.evaluate(XPATH_RULES[1], node,
                // XPathConstants.STRING);
                // String rpId = (String) xpath.evaluate(XPATH_RULES[3], node,
                // XPathConstants.STRING);
                String nodeId = node
                        .getAttribute(UtilsXML.GRANT_NAMEATTRIBUTE_CODE);
                String rgId = node
                        .getAttribute(UtilsXML.GRANT_NAMEATTRIBUTE_RGID);
                Project clone = null;
                // use dto to fill dynamic metadata
                AnagraficaObjectDTO dto = new AnagraficaObjectDTO();
                AnagraficaObjectDTO clonedto = new AnagraficaObjectDTO();
                boolean update = false; // if update a true then set field to
                                        // null
                                        // on case of empty element
                if (nodeId == null || nodeId.isEmpty())
                {
                    log.error("Grant discarded ( code not founded) [position grant: "
                            + i + "]");
                    throw new RuntimeException(
                            "Grant discarded (code not founded whilst rgId is on xml) [position grant: "
                                    + i + "]");

                }
                else
                {
                    // if there is rgid then try to get grant by code
                    // and
                    // set to null all structural metadata lists
                    log.info("Grant staffNo : " + nodeId
                            + " / rg identifier : " + rgId);
                    if (rgId != null && !rgId.isEmpty())
                    {
                        grant = applicationService
                                .getResearcherGrantByCode(nodeId);
                        if (grant == null)
                        {
                            log.error("Grant discarded (code not founded whilst rgId is on xml) [position grant: "
                                    + i + "]");
                            ;
                            throw new RuntimeException(
                                    "Grant discarded (code not founded whilst rgId is on xml) [position grant: "
                                            + i + "]");
                        }
                        else
                        {
                            if (!rgId.equals(grant.getId().toString()))
                            {
                                log.error("Grant discarded (rgId don't match persistent identifier) [position grant: "
                                        + i + "]");
                                throw new RuntimeException(
                                        "Grant discarded (rgId don't match persistent identifier) [position grant: "
                                                + i + "]");
                            }
                        }
                        // clone dynamic data and structural on dto

                        clone = (Project) grant.clone();
                        ProjectAdditionalFieldStorage additionalTemp = new ProjectAdditionalFieldStorage();
                        clone.setDynamicField(additionalTemp);
                        additionalTemp.duplicaAnagrafica(grant
                                .getDynamicField());
                        update = true;
                    }
                    else
                    {
                        // here there is perhaps a new grant
                        grant = applicationService
                                .getResearcherGrantByCode(nodeId);
                        if (grant == null)
                        {
                            grant = new Project();
                            grant.setSourceID(nodeId);
                            // use -active in command line to change default
                            // status to active.
                            grant.setStatus(status);

                            clone = (Project) grant.clone();
                            ProjectAdditionalFieldStorage additionalTemp = new ProjectAdditionalFieldStorage();
                            clone.setDynamicField(additionalTemp);
                            additionalTemp.duplicaAnagrafica(grant
                                    .getDynamicField());

                        }
                        else
View Full Code Here

TOP

Related Classes of org.dspace.app.cris.model.Project

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.