Revision 48571
Added by Panagiotis Kanakakis almost 7 years ago
modules/uoa-goldoa-service/branches/hibernate/src/test/java/unitest/ManageRequestsTest.java | ||
---|---|---|
245 | 245 |
public void importCSVRequests() { |
246 | 246 |
|
247 | 247 |
String csv = "User email,Project Grant Number,DOI,Acceptance Date,Publication Identifier Type,Publication Identifier value,License,APC,APC currency,Discount,Co-Funder Name,Co-funder discount percentage (';' separated)\n" + |
248 |
"pkanakakis@di.uoa.gr ,641489,10.1002/0470841559.ch10 ,2015-05-27,doi,doiValue,testLicense,1000,EUR,0,1675 Foundation,0\n "+
|
|
249 |
"pkanakakis@di.uoa.gr ,100016,10.1002/0470841559.ch10 ,2015-05-27,doi,doiValue,testLicense,1000,EUR,0,1675 Foundation,0\n"+
|
|
250 |
"pkanakakis@di.uoa.gr ,100016,10.1002/0470841559.ch2,2015-05-27,doi,doiValue,testLicense,1000,EUR,0,1675 Foundation,0";
|
|
248 |
"pkanakakis@di.uoa.gr ,641489,10.1002/0470841559.ch10 ,2015-05-27,doi,doiValue,testLicense,1000,EUR,0\n "+ |
|
249 |
"pkanakakis@di.uoa.gr ,100016,10.1002/0470841559.ch10 ,2015-05-27,doi,doiValue,testLicense,1000,EUR,0\n"+ |
|
250 |
"pkanakakis@di.uoa.gr ,100016,10.1002/0470841559.ch2,2015-05-27,doi,doiValue,testLicense,1000,EUR,0"; |
|
251 | 251 |
//"pkanakakis@di.uoa.gr,100016,10.1002/0470841559.ch1,2015-05-27,doi,doiValue,licenseValue,1000,EUR,10.00,,"; |
252 | 252 |
//"pkanakakis@di.uoa.gr,100016,10.1002/0470841559.ch10,2015-05-27,doi,doiValue,licenseValue,1000,EUR,10.00,,"; |
253 | 253 |
System.out.println(csv); |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/RequestManagerImpl.java | ||
---|---|---|
667 | 667 |
String apc = line.length>=7?line[7].trim():null; |
668 | 668 |
String apcCurrency = line.length>=8?line[8].trim():null; |
669 | 669 |
String discount = line.length>=9?line[9].trim():null; |
670 |
String coFunderName = line.length>10?line[10].trim():null; |
|
671 |
String coFunderDiscountPercentage = line.length>=11?line[11].trim():null; |
|
672 | 670 |
|
673 | 671 |
importRequestFromCSV(userEmail,grant,doi,acceptanceDate, |
674 | 672 |
identifierType,identifierValue,publicationLicense,apc, |
675 |
apcCurrency,discount,coFunderName,coFunderDiscountPercentage);
|
|
673 |
apcCurrency,discount); |
|
676 | 674 |
} |
677 | 675 |
} |
678 | 676 |
|
679 | 677 |
|
680 | 678 |
private void importRequestFromCSV(String userEmail, String grant, String doi, String acceptanceDate, |
681 | 679 |
String identifierType, String identifierValue, String publicationLicense, |
682 |
String apc, String apcCurrency, String discount, String coFunderName, |
|
683 |
String coFunderDiscountPercentage) |
|
680 |
String apc, String apcCurrency, String discount) |
|
684 | 681 |
throws PersonManagerException, ParseException, ManagerException { |
685 | 682 |
|
686 | 683 |
User user = null; |
... | ... | |
714 | 711 |
else if(publication.getPublisher()!=null) |
715 | 712 |
publisherManager.savePublisher(publication.getPublisher()); |
716 | 713 |
|
717 |
List<RequestCoFunder> coFunders = this.parseFunders(coFunderName,coFunderDiscountPercentage); |
|
718 | 714 |
|
719 | 715 |
Request request = requestDAO.getRequestFromCSV(user,project,publication,acceptanceDate, |
720 | 716 |
identifierType,identifierValue,publicationLicense,apc, |
721 |
apcCurrency,discount,coFunders);
|
|
717 |
apcCurrency,discount); |
|
722 | 718 |
|
723 | 719 |
request.setId("L" + new SimpleDateFormat("yyyyMMdd-").format(new Date()) + requestDAO.getRequestId()); |
724 | 720 |
request.setEligibility(eligibilityManager.validate(request)); |
... | ... | |
729 | 725 |
|
730 | 726 |
} |
731 | 727 |
|
732 |
private List<RequestCoFunder> parseFunders(String coFunderName, String coFunderDiscountPercentage) { |
|
733 | 728 |
|
734 |
String[] funders = coFunderName!=null?coFunderName.split(";"):null; |
|
735 |
String[] discounts = coFunderDiscountPercentage!=null?coFunderDiscountPercentage.split(";"):null; |
|
736 |
List<RequestCoFunder> coFunders = null; |
|
737 |
|
|
738 |
if(funders!=null) { |
|
739 |
int i = 0; |
|
740 |
coFunders = new ArrayList<>(); |
|
741 |
for (String funderName : funders) { |
|
742 |
RequestCoFunder rcf = new RequestCoFunder(); |
|
743 |
RequestCoFunderPK rcfpk = new RequestCoFunderPK(); |
|
744 |
|
|
745 |
Funder f = null; |
|
746 |
List<Object> rs = searchManager.search(SearchManager.TYPE.FUNDER, funderName); |
|
747 |
if (rs.size() == 0) |
|
748 |
System.out.println("funder problem"); |
|
749 |
//throw new ManagerException("Project with specified grant not found!"); |
|
750 |
else |
|
751 |
f = (Funder) rs.get(0); |
|
752 |
|
|
753 |
rcfpk.setFunder(f); |
|
754 |
rcf.setPercentage(Float.parseFloat(discounts[i])); |
|
755 |
rcf.setPk(rcfpk); |
|
756 |
|
|
757 |
coFunders.add(rcf); |
|
758 |
i++; |
|
759 |
} |
|
760 |
} |
|
761 |
return coFunders; |
|
762 |
} |
|
763 |
|
|
764 | 729 |
@Override |
765 | 730 |
public BigInteger getActiveNumber() { |
766 | 731 |
return requestDAO.getActiveNumber(); |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/dao/RequestDAO.java | ||
---|---|---|
829 | 829 |
|
830 | 830 |
public Request getRequestFromCSV(User user, Project project, Publication publication, String acceptanceDate, |
831 | 831 |
String identifierType, String identifierValue, String publicationLicense, |
832 |
String apc, String apcCurrency, String discount, |
|
833 |
List<RequestCoFunder> coFunders) throws ParseException { |
|
832 |
String apc, String apcCurrency, String discount) throws ParseException { |
|
834 | 833 |
|
835 | 834 |
Request request = new Request(); |
836 | 835 |
request.setUser(user); |
... | ... | |
851 | 850 |
request.setCurrency(Currency.valueOf(apcCurrency)); |
852 | 851 |
request.setDiscount(Float.parseFloat(discount)); |
853 | 852 |
request.setPublication(publication); |
854 |
|
|
855 |
if(coFunders!=null ){ |
|
856 |
for (RequestCoFunder rc : coFunders) |
|
857 |
rc.getPk().setRequest(request); |
|
858 |
} |
|
859 |
|
|
860 | 853 |
request.setStatus(Request.RequestStatus.LIBRARY_FUND_PAID); |
861 |
request.setRequestCoFunders(coFunders); |
|
862 | 854 |
return request; |
863 | 855 |
} |
864 | 856 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/eligibility/ChainEligibilityManager.java | ||
---|---|---|
39 | 39 |
@Override |
40 | 40 |
public Eligibility validate(Request request) { |
41 | 41 |
try { |
42 |
logger.debug("Managers size : " + managers.size() ); |
|
43 |
logger.debug("Request status: " + request.getStatus().getValue()); |
|
44 | 42 |
|
45 |
System.out.println("Managers size : " + managers.size() ); |
|
46 |
System.out.println("Request status: " + request.getStatus().getValue()); |
|
47 |
|
|
48 |
|
|
49 |
for(int i=0;i<managers.size();i++) |
|
50 |
System.out.println(managers.get(i).getClass()); |
|
51 |
|
|
52 |
|
|
53 | 43 |
Eligibility eligibility = new Eligibility(Eligibility.Status.OK); |
54 | 44 |
|
55 | 45 |
Request.RequestStatus status = request.getStatus(); |
... | ... | |
63 | 53 |
case ACCOUNTING_PAID: |
64 | 54 |
return eligibility; |
65 | 55 |
default: |
66 |
for (EligibilityManager manager : managers) |
|
56 |
for (EligibilityManager manager : managers) {
|
|
67 | 57 |
eligibility.merge(manager.validate(request)); |
58 |
} |
|
68 | 59 |
|
69 | 60 |
return eligibility; |
70 | 61 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/eligibility/ProjectEligibiliyManager.java | ||
---|---|---|
88 | 88 |
|
89 | 89 |
if (!enddate.before(new Date())) { |
90 | 90 |
return new Eligibility(Eligibility.Status.NONO, stillRunningNono); |
91 |
} else if (enddate.after(new Date(System.currentTimeMillis() - expirationOk))) { |
|
91 |
} else if (enddate.after(new Date(System.currentTimeMillis() - expirationOk * 1000L * 60 * 60 * 24 * 30))) {
|
|
92 | 92 |
return Eligibility.OK; |
93 | 93 |
} else if (enddate.after(new Date((long) (System.currentTimeMillis() - (1.0f + expirationThreshold) * expirationOk)))) { |
94 | 94 |
return new Eligibility(Eligibility.Status.IFFY, expirationIffy); |
Also available in: Unified diff
- Bug fix on ProjectEligibilityManagr ( convert expirationOK to miliseconds )