private List<OrganizationVO> getAffiliatedOrganizations(PubItemVO pubItem) { List<CreatorVO> tempCreatorList; List<OrganizationVO> tempOrganizationList = new ArrayList<OrganizationVO>(); List<OrganizationVO> sortOrganizationList = new ArrayList<OrganizationVO>(); tempCreatorList = pubItem.getMetadata().getCreators(); int affiliationPosition = 0; for (int i = 0; i < tempCreatorList.size(); i++) { CreatorVO creator = new CreatorVO(); creator = tempCreatorList.get(i); if (creator.getPerson() != null) { if (creator.getPerson().getOrganizations().size() > 0) { for (int listSize = 0; listSize < creator.getPerson().getOrganizations().size(); listSize++) { tempOrganizationList.add(creator.getPerson().getOrganizations().get(listSize)); } for (int j = 0; j < tempOrganizationList.size(); j++) { // if the organization is not in the list already, put // it in. if (!sortOrganizationList.contains(tempOrganizationList.get(j))) { affiliationPosition++; sortOrganizationList.add(tempOrganizationList.get(j)); } } } } } // save the List in the backing bean for later use. return sortOrganizationList; }
@Override public boolean validate(ValidatorContext context, List<SourceVO> sources) { boolean ok = true; if (sources != null) { int i = 1; for (SourceVO sourceVO : sources) { if (sourceVO.getCreators() != null) { int j = 1; for (CreatorVO creatorVO : sourceVO.getCreators()) { if (creatorVO.getRole() == null) { switch (creatorVO.getType()) { case ORGANIZATION: OrganizationVO o = creatorVO.getOrganization(); if (o.getName() != null || o.getAddress() != null) { context.addError( ValidationError.create(ErrorMessages.SOURCE_CREATOR_ROLE_NOT_PROVIDED) .setField("source[" + i + "].creator[" + j + "]")); ok = false; } break; case PERSON: PersonVO p = creatorVO.getPerson(); if (p.getFamilyName() != null || p.getGivenName() != null) { context.addError( ValidationError.create(ErrorMessages.SOURCE_CREATOR_ROLE_NOT_PROVIDED) .setField("source[" + i + "].creator[" + j + "]")); ok = false; } List<OrganizationVO> orgs = p.getOrganizations(); int z = 1; for (OrganizationVO organizationVO : orgs) { if (organizationVO.getName() != null || organizationVO.getAddress() != null) context.addError( ValidationError.create(ErrorMessages.SOURCE_CREATOR_ROLE_NOT_PROVIDED) .setField( "source[" + i + "].creator[" + j + "].organization[" + z + "]")); ok = false; z++; } // for break; } // switch } // if j++; } // for } // if i++; } // for } // if return ok; }
private void logPubItemAction( PubItemVO pubItem, String ip, String userAgent, ItemAction action, String sessionId, boolean loggedIn, String referer, List<StatisticReportRecordParamVO> additionalParams) throws Exception { List<StatisticReportRecordParamVO> paramList = new ArrayList<StatisticReportRecordParamVO>(); /* * List<CreatorVO> creatorList = pubItem.getMetadata().getCreators(); String persAffIds = ""; * for(CreatorVO creator : creatorList) { if (creator.getPerson()!=null && * creator.getPerson().getIdentifier()!=null && * creator.getPerson().getIdentifier().getId()!=null && * !creator.getPerson().getIdentifier().getId().equals("")) { persAffIds += * creator.getPerson().getIdentifier().getId() + ","; } } StatisticReportRecordParamVO * persAffParam = new StatisticReportRecordParamVO(); persAffParam.setName("persAffId"); * persAffParam.setParamValue(new StatisticReportRecordStringParamValueVO(persAffIds)); * paramList.add(persAffParam); */ StatisticReportRecordParamVO oaParam = new StatisticReportRecordParamVO(); oaParam.setName("hasOAComponent"); oaParam.setParamValue( new StatisticReportRecordStringParamValueVO(String.valueOf(getHasOAComponent(pubItem)))); paramList.add(oaParam); String authorIds = "{"; String orgIds = "{"; List<CreatorVO> creatorList = pubItem.getMetadata().getCreators(); for (CreatorVO creator : creatorList) { if (creator.getPerson() != null && creator.getPerson().getIdentifier() != null && creator.getPerson().getIdentifier().getId() != null && !creator.getPerson().getIdentifier().getId().equals("")) { // sl.logAuthorAction(sessionId, ip, creator.getPerson().getIdentifier().getId(), loggedIn, // referer, "pubman", null, AdminHelper.getAdminUserHandle()); authorIds += creator.getPerson().getIdentifier().getId() + ","; /* * StatisticReportRecordParamVO authorIdsParam = new StatisticReportRecordParamVO(); * authorIdsParam.setName("authorId"); authorIdsParam.setParamValue(new * StatisticReportRecordStringParamValueVO(creator.getPerson().getIdentifier().getId())); * paramList.add(authorIdsParam); */ } /* * if(creator.getPerson()!=null && creator.getPerson().getOrganizationsSize()>0) { * for(OrganizationVO org : creator.getPerson().getOrganizations()) { if(org.getIdentifier()!= * null && !org.getIdentifier().equals("")) { //sl.logOrgAction(sessionId, ip, * org.getIdentifier(), loggedIn, referer, "pubman", null, AdminHelper.getAdminUserHandle()); * orgIds += org.getIdentifier() + ","; * * // StatisticReportRecordParamVO orgIdsParam = new StatisticReportRecordParamVO(); // * orgIdsParam.setName("orgId"); // orgIdsParam.setParamValue(new * StatisticReportRecordStringParamValueVO(org.getIdentifier())); // * paramList.add(orgIdsParam); * * } } } */ if (creator.getOrganization() != null && creator.getOrganization().getIdentifier() != null && !creator.getOrganization().getIdentifier().equals("")) { // sl.logOrgAction(sessionId, ip, creator.getOrganization().getIdentifier(), loggedIn, // referer, "pubman", null, AdminHelper.getAdminUserHandle()); orgIds += creator.getOrganization().getIdentifier() + ","; /* * StatisticReportRecordParamVO orgIdsParam = new StatisticReportRecordParamVO(); * orgIdsParam.setName("orgId"); orgIdsParam.setParamValue(new * StatisticReportRecordStringParamValueVO(creator.getOrganization().getIdentifier())); * paramList.add(orgIdsParam); */ } } for (OrganizationVO org : getAffiliatedOrganizations(pubItem)) { if (org.getIdentifier() != null && !org.getIdentifier().equals("")) { orgIds += org.getIdentifier() + ","; } } authorIds += "}"; orgIds += "}"; StatisticReportRecordParamVO authorIdsParam = new StatisticReportRecordParamVO(); authorIdsParam.setName("authorIds"); authorIdsParam.setParamValue(new StatisticReportRecordStringParamValueVO(authorIds)); paramList.add(authorIdsParam); StatisticReportRecordParamVO orgIdsParam = new StatisticReportRecordParamVO(); orgIdsParam.setName("orgIds"); orgIdsParam.setParamValue(new StatisticReportRecordStringParamValueVO(orgIds)); paramList.add(orgIdsParam); if (additionalParams != null) { paramList.addAll(additionalParams); } // InitialContext ic = new InitialContext(); // StatisticLogger sl = (StatisticLogger) ic.lookup(StatisticLogger.SERVICE_NAME); statisticLogger.logItemAction( sessionId, ip, userAgent, new PubItemVO(pubItem), action, loggedIn, referer, "pubman", paramList, AdminHelper.getAdminUserHandle()); }