Package org.dspace.app.cris.model

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


     *            the rp authority key (i.e. rp00024)
     * @return the ResearcherPage; null if the key is invalid
     */
    public ResearcherPage getResearcherByAuthorityKey(String authorityKey)
    {
        ResearcherPage rp = null;
        try
        {
            rp = get(ResearcherPage.class,
                    ResearcherPageUtils.getRealPersistentIdentifier(
                            authorityKey, ResearcherPage.class));
View Full Code Here


            boolean silent = line.hasOption('s');
            Item[] items = null;
            if (line.hasOption('r'))
            {
                rpId = ResearcherPageUtils.getRealPersistentIdentifier(line.getOptionValue("r"),ResearcherPage.class);
                ResearcherPage rp = applicationService.get(
                        ResearcherPage.class, rpId);

                if (rp == null)
                {
                    if (!silent)
                    {
                        System.out.println("RP not exist...exit");
                    }
                    log.info("RP not exist...exit");
                    System.exit(0);
                }

                log.info("Use browse indexing");

                BrowseIndex bi = BrowseIndex.getBrowseIndex(plugInBrowserIndex);
                // now start up a browse engine and get it to do the work for us
                BrowseEngine be = new BrowseEngine(dspaceContext);

                String authKey = ResearcherPageUtils.getPersistentIdentifier(rp);

                // set up a BrowseScope and start loading the values into it
                BrowserScope scope = new BrowserScope(dspaceContext);
                scope.setBrowseIndex(bi);
                // scope.setOrder(order);
                scope.setFilterValue(authKey);
                scope.setAuthorityValue(authKey);
                scope.setResultsPerPage(Integer.MAX_VALUE);
                scope.setBrowseLevel(1);

                BrowseInfo binfo = be.browse(scope);
                log.debug("Find " + binfo.getResultCount()
                        + "item(s) for the reseracher " + authKey);
                items = binfo.getItemResults(dspaceContext);
               
                if (!silent && rp != null)
                {
                    System.out.println(MESSAGE_ONE);
                   
                    // interactive mode
                    System.out.println("Attempting to remove Researcher Page:");
                    System.out.println("StaffNo:" + rp.getSourceID());
                    System.out.println("FullName:" + rp.getFullName());
                    System.out.println("the researcher has " + items.length + " relation(s) with item(s) in the HUB");
                    System.out.println();

                    System.out.println(QUESTION_ONE);
                    InputStreamReader isr = new InputStreamReader(System.in);
View Full Code Here

                log
                        .info("Script launched with -s parameter...it will work on researcher with rp identifier "
                                + rp);
                rps = new LinkedList<ResearcherPage>();
                ResearcherPage researcher = applicationService
                        .get(ResearcherPage.class, Integer.parseInt(rp
                                .substring(2)));
                rps.add(researcher);
                reIndexItems(rps, applicationService);
            }
View Full Code Here

        {
            // nothing to do
            return;
        }

        ResearcherPage cris = (ResearcherPage) object;

        Context context = null;
        try
        {
            context = new Context();
            context.turnOffAuthorisationSystem();
            if(cris.getEpersonID()!=null) {
                delete(cris.getEpersonID(), cris.getId(), context);
            }
            context.complete();
        }
        catch (Exception e)
        {
            log.error("Failed to delete resource policy attached to RP just deleted"
                    + cris.getPublicPath() + " uuid:" + cris.getUuid());
            emailException(e);
        }
        finally
        {
            if (context != null && context.isValid())
View Full Code Here

        {
            // nothing to do
            return;
        }

        ResearcherPage cris = (ResearcherPage) object;

        Context context = null;
        try
        {
            context = new Context();
            context.turnOffAuthorisationSystem();
            if (cris.getEpersonID() != null)
            {
                ResourcePolicy resourcePolicy = ResourcePolicy.create(context);
                resourcePolicy.setAction(Constants.ADMIN);
                resourcePolicy.setEPerson(cris.getDspaceUser());
                resourcePolicy.setResource(cris);
                resourcePolicy.setResourceType(CrisConstants.RP_TYPE_ID);
                resourcePolicy.setResourceID(cris.getID());
                resourcePolicy.update();
            }
            context.complete();
        }
        catch (Exception e)
        {
            log.error("Failed to delete resource policy attached to RP just deleted"
                    + cris.getPublicPath() + " uuid:" + cris.getUuid());
            emailException(e);
        }
        finally
        {
            if (context != null && context.isValid())
View Full Code Here

        {
            // nothing to do
            return;
        }

        ResearcherPage cris = (ResearcherPage) object;

        Context context = null;
        try
        {
            context = new Context();
            context.turnOffAuthorisationSystem();
            if ((cris.getOldEpersonID() != null && !cris.getOldEpersonID()
                    .equals(cris.getEpersonID()))
                    || (cris.getOldEpersonID() == null && cris.getEpersonID() != null))
            {
                if (cris.getEpersonID() != null)
                {
                    ResourcePolicy resourcePolicy = ResourcePolicy
                            .create(context);
                    resourcePolicy.setAction(Constants.ADMIN);
                    resourcePolicy.setEPerson(cris.getDspaceUser());
                    resourcePolicy.setResource(cris);
                    resourcePolicy.setResourceType(CrisConstants.RP_TYPE_ID);
                    resourcePolicy.setResourceID(cris.getID());
                    resourcePolicy.update();
                }
                if (cris.getOldEpersonID() != null)
                {
                    delete(cris.getOldEpersonID(), cris.getId(), context);
                }
               
            }
            context.complete();
        }
        catch (Exception e)
        {
            log.error("Failed to delete resource policy attached to RP just deleted"
                    + cris.getPublicPath() + " uuid:" + cris.getUuid());
            emailException(e);
        }
        finally
        {
            if (context != null && context.isValid())
View Full Code Here

    public void onPostLoad(PostLoadEvent event)
    {
        Object object = event.getEntity();
        if (object instanceof ResearcherPage)
        {
            ResearcherPage rp = (ResearcherPage) object;
            rp.setOldEpersonID(rp.getEpersonID());
        }
    }
View Full Code Here

    public void onPostLoad(PostLoadEvent event)
    {
        Object object = event.getEntity();
        if (object instanceof ResearcherPage)
        {
            ResearcherPage rp = (ResearcherPage) object;

            String oldNames = "";

            Set<String> oldNamesSet = new TreeSet<String>();
            if(rp.getFullName()!=null) {
                oldNamesSet.add(rp.getFullName());
            }
            if (rp.getPreferredName().getValue() != null)
            {
                oldNamesSet.add(rp.getPreferredName().getValue()+rp.getPreferredName().getVisibility());
            }
            if (rp.getTranslatedName().getValue() != null)
            {
                oldNamesSet.add(rp.getTranslatedName().getValue()+rp.getTranslatedName().getVisibility());
            }
            for (RestrictedField variant : rp.getVariants())
            {
                if (variant.getValue() != null)
                {
                    oldNamesSet.add(variant.getValue()+variant.getVisibility());
                }
            }

            for (String oldName : oldNamesSet)
            {
                oldNames += oldName;
            }

            rp.setOldNames(oldNames);

        }
    }
View Full Code Here

    public boolean onPreUpdate(PreUpdateEvent event)
    {
        Object object = event.getEntity();
        if (object instanceof ResearcherPage)
        {
            ResearcherPage rp = (ResearcherPage) object;

            String newNames = "";
            String oldNames = rp.getOldNames();

            Set<String> newNamesSet = new TreeSet<String>();
            if(rp.getFullName()!=null) {
                newNamesSet.add(rp.getFullName());
            }
            if (rp.getPreferredName().getValue() != null) {
                newNamesSet.add(rp.getPreferredName().getValue()+rp.getPreferredName().getVisibility());
            }
            if (rp.getTranslatedName().getValue() != null)
            {
                newNamesSet.add(rp.getTranslatedName().getValue()+rp.getTranslatedName().getVisibility());
            }
            for (RestrictedField variant : rp.getVariants())
            {
                newNamesSet.add(variant.getValue()+rp.getTranslatedName().getVisibility());
            }

            for (String newName : newNamesSet)
            {
                newNames += newName;
View Full Code Here

        log.info("Start import " + new Date());
        // foreach researcher element in xml
        for (int i = 0; i < researchers.size(); i++)
        {
            log.info("Number " + i + " of " + researchers.size());
            ResearcherPage researcher = null;
            try
            {
                Element node = researchers.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.NAMEATTRIBUTE_STAFF_NO);
                String rpId = node.getAttribute(UtilsXML.NAMEATTRIBUTE_RPID);
                ResearcherPage 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("Researcher discarded ( staffNo not founded) [position researcher: "
                            + i + "]");
                    throw new RuntimeException(
                            "Researcher discarded (staffNo not founded whilst rpId is on xml) [position researcher: "
                                    + i + "]");

                }
                else
                {
                    // if there is rpid then try to get researcher by staffNo
                    // and
                    // set to null all structural metadata lists
                    log.info("Researcher staffNo : " + nodeId
                            + " / rp identifier : " + rpId);
                    if (rpId != null && !rpId.isEmpty())
                    {
                        researcher = applicationService
                                .getResearcherPageByStaffNo(nodeId);
                        if (researcher == null)
                        {
                            log.error("Researcher discarded (staffNo not founded whilst rpId is on xml) [position researcher: "
                                    + i + "]");
                            ;
                            throw new RuntimeException(
                                    "Researcher discarded (staffNo not founded whilst rpId is on xml) [position researcher: "
                                            + i + "]");
                        }
                        else
                        {
                            if (!rpId.equals(ResearcherPageUtils
                                    .getPersistentIdentifier(researcher)))
                            {
                                log.error("Researcher discarded (rpId don't match persistent identifier) [position researcher: "
                                        + i + "]");
                                throw new RuntimeException(
                                        "Researcher discarded (staffNo not founded whilst rpId is on xml) [position researcher: "
                                                + i + "]");
                            }
                        }
                        // clone dynamic data and structural on dto

                        clone = (ResearcherPage) researcher.clone();
                        RPAdditionalFieldStorage additionalTemp = new RPAdditionalFieldStorage();
                        clone.setDynamicField(additionalTemp);
                        additionalTemp.duplicaAnagrafica(researcher
                                .getDynamicField());
                        update = true;

                    }
                    else
                    {
                        // here there is perhaps a new researcher
                        researcher = applicationService
                                .getResearcherPageByStaffNo(nodeId);
                        if (researcher == null)
                        {
                            researcher = new ResearcherPage();
                            researcher.setSourceID(nodeId);
                            // added by Allen: all newly added researchers are
                            // inactive by default
                            // use -active in command line to change default
                            // status to active.
                            researcher.setStatus(status);

                            clone = (ResearcherPage) researcher.clone();
                            RPAdditionalFieldStorage additionalTemp = new RPAdditionalFieldStorage();
                            clone.setDynamicField(additionalTemp);
                            additionalTemp.duplicaAnagrafica(researcher
                                    .getDynamicField());
                        }
                        else
                        {
                            log.error("Researcher discarded (staffNo " + nodeId
                                    + " already exist) [position researcher: "
                                    + i + "]");
                            throw new RuntimeException(
                                    "Researcher discarded (staffNo "
                                            + nodeId
                                            + " already exist) [position researcher: "
                                            + i + "]");
                        }
                    }
                }

                AnagraficaUtils.fillDTO(dto, researcher.getDynamicField(),
                        realFillTPS);

                // one-shot fill and reverse to well-format clonedto and clean
                // empty
                // data
                AnagraficaUtils.fillDTO(clonedto, clone.getDynamicField(),
                        realFillTPS);

                AnagraficaUtils.reverseDTO(clonedto, clone.getDynamicField(),
                        realFillTPS);

                AnagraficaUtils.fillDTO(clonedto, clone.getDynamicField(),
                        realFillTPS);
                importDynAXML(applicationService, realFillTPS, node, dto,
                        clonedto, update);

                for (IContainable containable : structuralFillField)
View Full Code Here

TOP

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

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.