1 |
35691
|
stefania.m
|
package eu.dnetlib.client.fundingrequest.existingrequests;
|
2 |
|
|
|
3 |
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
4 |
41226
|
stefania.m
|
import com.github.gwtbootstrap.client.ui.Modal;
|
5 |
|
|
import com.github.gwtbootstrap.client.ui.constants.BackdropType;
|
6 |
36971
|
stefania.m
|
import com.google.gwt.core.client.GWT;
|
7 |
35691
|
stefania.m
|
import com.google.gwt.event.dom.client.ClickEvent;
|
8 |
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
9 |
35700
|
stefania.m
|
import com.google.gwt.user.client.History;
|
10 |
36971
|
stefania.m
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
11 |
35691
|
stefania.m
|
import com.google.gwt.user.client.ui.FlowPanel;
|
12 |
|
|
import com.google.gwt.user.client.ui.IsWidget;
|
13 |
|
|
import com.google.gwt.user.client.ui.Widget;
|
14 |
41226
|
stefania.m
|
import eu.dnetlib.client.ContactForm;
|
15 |
|
|
import eu.dnetlib.client.DOIAndRepositoryForm;
|
16 |
36971
|
stefania.m
|
import eu.dnetlib.client.DataService;
|
17 |
|
|
import eu.dnetlib.client.DataServiceAsync;
|
18 |
35751
|
stefania.m
|
import eu.dnetlib.client.fundingrequest.newrequest.EligibilityDisplayWidget;
|
19 |
|
|
import eu.dnetlib.client.fundingrequest.stepinfo.*;
|
20 |
46067
|
panagiotis
|
import eu.dnetlib.goldoa.domain.Comment;
|
21 |
36971
|
stefania.m
|
import eu.dnetlib.goldoa.domain.Currency;
|
22 |
35751
|
stefania.m
|
import eu.dnetlib.goldoa.domain.Request;
|
23 |
46067
|
panagiotis
|
import eu.dnetlib.goldoa.domain.RequestComment;
|
24 |
35691
|
stefania.m
|
|
25 |
46067
|
panagiotis
|
import java.util.ArrayList;
|
26 |
|
|
import java.util.List;
|
27 |
|
|
|
28 |
35691
|
stefania.m
|
/**
|
29 |
|
|
* Created by stefania on 3/26/15.
|
30 |
|
|
*/
|
31 |
|
|
public class ExistingRequestElement implements IsWidget {
|
32 |
|
|
|
33 |
|
|
private FlowPanel requestInfoPanel = new FlowPanel();
|
34 |
|
|
|
35 |
35751
|
stefania.m
|
private FlowPanel requestSummaryPanel = new FlowPanel();
|
36 |
35839
|
stefania.m
|
private FlowPanel firstDivider = new FlowPanel();
|
37 |
|
|
private FlowPanel secondDivider = new FlowPanel();
|
38 |
35691
|
stefania.m
|
|
39 |
|
|
private FlowPanel actionButtons = new FlowPanel();
|
40 |
|
|
private Button goToFundingWizard = new Button("Go to Funding Wizard");
|
41 |
41226
|
stefania.m
|
private Button addDOI = new Button("Add DOI / repository");
|
42 |
35691
|
stefania.m
|
|
43 |
36971
|
stefania.m
|
private DataServiceAsync dataService = GWT.create(DataService.class);
|
44 |
|
|
|
45 |
41226
|
stefania.m
|
private PublicationUpdatedListener publicationUpdatedListener;
|
46 |
|
|
|
47 |
45767
|
panagiotis
|
public ExistingRequestElement(final Request request) {
|
48 |
35691
|
stefania.m
|
|
49 |
|
|
requestInfoPanel.addStyleName("requestInfoPanel");
|
50 |
|
|
|
51 |
36865
|
stefania.m
|
requestSummaryPanel.addStyleName("requestDetailedInfoPanel");
|
52 |
|
|
|
53 |
45767
|
panagiotis
|
if(request.getResearcher()!=null) {
|
54 |
|
|
ResearcherInlineInfo researcherInlineInfo = new ResearcherInlineInfo(request.getResearcher());
|
55 |
35839
|
stefania.m
|
requestSummaryPanel.add(researcherInlineInfo.asWidget());
|
56 |
|
|
}
|
57 |
35691
|
stefania.m
|
|
58 |
45767
|
panagiotis
|
if(request.getProject()!=null) {
|
59 |
|
|
ProjectInlineInfo projectInlineInfo = new ProjectInlineInfo(request.getProject());
|
60 |
35839
|
stefania.m
|
requestSummaryPanel.add(projectInlineInfo.asWidget());
|
61 |
|
|
}
|
62 |
35751
|
stefania.m
|
|
63 |
45767
|
panagiotis
|
if(request.getPublication()!=null) {
|
64 |
|
|
PublicationInlineInfo publicationInlineInfo = new PublicationInlineInfo(request.getPublication());
|
65 |
35839
|
stefania.m
|
requestSummaryPanel.add(publicationInlineInfo.asWidget());
|
66 |
|
|
}
|
67 |
35751
|
stefania.m
|
|
68 |
|
|
float apc = 0;
|
69 |
|
|
float discount = 0;
|
70 |
|
|
|
71 |
45767
|
panagiotis
|
if(request.getPublication()!=null && request.getPublication().getJournal()!=null) {
|
72 |
|
|
JournalInlineInfo journalInlineInfo = new JournalInlineInfo(request.getPublication().getJournal());
|
73 |
35839
|
stefania.m
|
requestSummaryPanel.add(journalInlineInfo.asWidget());
|
74 |
45767
|
panagiotis
|
apc = request.getPublication().getJournal().getApc();
|
75 |
|
|
discount = request.getPublication().getJournal().getDiscount();
|
76 |
35751
|
stefania.m
|
}
|
77 |
|
|
|
78 |
45767
|
panagiotis
|
if(request.getPublication()!=null && request.getPublication().getPublisher()!=null) {
|
79 |
|
|
PublisherInlineInfo publisherInlineInfo = new PublisherInlineInfo(request.getPublication().getPublisher());
|
80 |
35839
|
stefania.m
|
requestSummaryPanel.add(publisherInlineInfo.asWidget());
|
81 |
45767
|
panagiotis
|
apc = request.getPublication().getPublisher().getApc();
|
82 |
|
|
discount = request.getPublication().getPublisher().getDiscount();
|
83 |
35751
|
stefania.m
|
}
|
84 |
|
|
|
85 |
45767
|
panagiotis
|
if(request.getPublication()!=null && request.getPublication().getLicense()!=null) {
|
86 |
|
|
LicenseFullInfo licenseFullInfo = new LicenseFullInfo(request.getPublication().getLicense());
|
87 |
41562
|
stefania.m
|
requestSummaryPanel.add(licenseFullInfo.asWidget());
|
88 |
|
|
}
|
89 |
|
|
|
90 |
45767
|
panagiotis
|
if(request.getProjectparticipation()!=null && request.getFundingrequested()!=null) {
|
91 |
36971
|
stefania.m
|
|
92 |
45767
|
panagiotis
|
if(!request.getCurrency().equals(Currency.EUR)) {
|
93 |
36971
|
stefania.m
|
|
94 |
|
|
final float finalApc = apc;
|
95 |
|
|
final float finalDiscount = discount;
|
96 |
45767
|
panagiotis
|
dataService.convert(request.getCurrency(), Currency.EUR, request.getFundingrequested(), new AsyncCallback<Float>() {
|
97 |
36971
|
stefania.m
|
|
98 |
|
|
@Override
|
99 |
|
|
public void onFailure(Throwable throwable) {
|
100 |
45767
|
panagiotis
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, finalApc, finalDiscount, request.getCurrency(), 0);
|
101 |
36971
|
stefania.m
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
@Override
|
105 |
|
|
public void onSuccess(Float aFloat) {
|
106 |
45767
|
panagiotis
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, finalApc, finalDiscount, request.getCurrency(), aFloat);
|
107 |
36971
|
stefania.m
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
108 |
|
|
}
|
109 |
|
|
});
|
110 |
|
|
} else {
|
111 |
45767
|
panagiotis
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, apc, discount, request.getCurrency(), 0);
|
112 |
36971
|
stefania.m
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
113 |
|
|
}
|
114 |
35751
|
stefania.m
|
}
|
115 |
|
|
|
116 |
45767
|
panagiotis
|
if(request.getInvoice()!=null) {
|
117 |
|
|
InvoiceInlineInfo invoiceInlineInfo = new InvoiceInlineInfo(request.getInvoice());
|
118 |
36070
|
stefania.m
|
requestSummaryPanel.add(invoiceInlineInfo.asWidget());
|
119 |
|
|
}
|
120 |
|
|
|
121 |
45767
|
panagiotis
|
if(request.getBankAccount()!=null &&
|
122 |
|
|
((request.getBankAccount().getBankName()!=null && !request.getBankAccount().getBankName().equals(""))
|
123 |
|
|
|| (request.getBankAccount().getBankAddress()!=null && !request.getBankAccount().getBankAddress().equals(""))
|
124 |
|
|
|| (request.getBankAccount().getAccountHolder()!=null && !request.getBankAccount().getAccountHolder().equals(""))
|
125 |
|
|
|| (request.getBankAccount().getIban()!=null && !request.getBankAccount().getIban().equals(""))
|
126 |
|
|
|| (request.getBankAccount().getBankCode()!=null && !request.getBankAccount().getBankCode().equals("")))) {
|
127 |
|
|
BankAccountInlineInfo bankAccountInlineInfo = new BankAccountInlineInfo(request.getBankAccount());
|
128 |
36912
|
stefania.m
|
requestSummaryPanel.add(bankAccountInlineInfo.asWidget());
|
129 |
|
|
}
|
130 |
|
|
|
131 |
45767
|
panagiotis
|
if(request.getPublisher().getEmail()!=null) {
|
132 |
|
|
PublisherContactInfo publisherContactInfo = new PublisherContactInfo(request.getPublisher().getEmail());
|
133 |
37080
|
stefania.m
|
requestSummaryPanel.add(publisherContactInfo.asWidget());
|
134 |
|
|
}
|
135 |
|
|
|
136 |
35691
|
stefania.m
|
actionButtons.addStyleName("requestInfoActionButtons");
|
137 |
|
|
|
138 |
|
|
goToFundingWizard.addStyleName("requestInfoActionButton");
|
139 |
|
|
goToFundingWizard.addClickHandler(new ClickHandler() {
|
140 |
|
|
@Override
|
141 |
|
|
public void onClick(ClickEvent event) {
|
142 |
45767
|
panagiotis
|
History.newItem("newFundingRequest." + request.getId());
|
143 |
35691
|
stefania.m
|
}
|
144 |
|
|
});
|
145 |
|
|
|
146 |
41226
|
stefania.m
|
addDOI.addStyleName("requestInfoActionButton");
|
147 |
|
|
addDOI.addClickHandler(new ClickHandler() {
|
148 |
|
|
@Override
|
149 |
|
|
public void onClick(ClickEvent event) {
|
150 |
|
|
|
151 |
|
|
final Modal addDOIAndRepositoryModal = new Modal();
|
152 |
|
|
|
153 |
|
|
addDOIAndRepositoryModal.addStyleName("contactModal");
|
154 |
|
|
addDOIAndRepositoryModal.setTitle("Add DOI and Repository");
|
155 |
|
|
addDOIAndRepositoryModal.setAnimation(true);
|
156 |
|
|
addDOIAndRepositoryModal.setBackdrop(BackdropType.STATIC);
|
157 |
|
|
addDOIAndRepositoryModal.setDynamicSafe(true);
|
158 |
|
|
|
159 |
45767
|
panagiotis
|
DOIAndRepositoryForm doiAndRepositoryForm = new DOIAndRepositoryForm(request.getPublication());
|
160 |
41226
|
stefania.m
|
DOIAndRepositoryForm.DOIAndRepositorySubmittedListener doiAndRepositorySubmittedListener =
|
161 |
|
|
new DOIAndRepositoryForm.DOIAndRepositorySubmittedListener() {
|
162 |
|
|
@Override
|
163 |
|
|
public void doiAndRepositorySubmitted() {
|
164 |
|
|
addDOIAndRepositoryModal.hide();
|
165 |
|
|
if(publicationUpdatedListener!=null)
|
166 |
|
|
publicationUpdatedListener.publicationUpdated();
|
167 |
|
|
}
|
168 |
|
|
};
|
169 |
|
|
doiAndRepositoryForm.setDoiAndRepositorySubmittedListener(doiAndRepositorySubmittedListener);
|
170 |
|
|
|
171 |
|
|
addDOIAndRepositoryModal.add(doiAndRepositoryForm.asWidget());
|
172 |
|
|
|
173 |
|
|
addDOIAndRepositoryModal.show();
|
174 |
|
|
}
|
175 |
|
|
});
|
176 |
|
|
|
177 |
35839
|
stefania.m
|
firstDivider.addStyleName("uk-grid-divider");
|
178 |
|
|
secondDivider.addStyleName("uk-grid-divider");
|
179 |
35751
|
stefania.m
|
|
180 |
45767
|
panagiotis
|
EligibilityDisplayWidget eligibilityDisplayWidget = new EligibilityDisplayWidget(request.getEligibility());
|
181 |
35751
|
stefania.m
|
|
182 |
|
|
requestInfoPanel.add(eligibilityDisplayWidget.asWidget());
|
183 |
35839
|
stefania.m
|
requestInfoPanel.add(firstDivider);
|
184 |
35751
|
stefania.m
|
requestInfoPanel.add(requestSummaryPanel);
|
185 |
35839
|
stefania.m
|
|
186 |
45767
|
panagiotis
|
if(!request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PAID) || (request.getRequestComments()!=null && !request.getRequestComments().isEmpty())) {
|
187 |
38818
|
stefania.m
|
|
188 |
35839
|
stefania.m
|
requestInfoPanel.add(secondDivider);
|
189 |
38818
|
stefania.m
|
|
190 |
45767
|
panagiotis
|
if(request.getRequestComments()!=null && !request.getRequestComments().isEmpty()) {
|
191 |
46067
|
panagiotis
|
List<Comment> comments = new ArrayList<>();
|
192 |
|
|
for(RequestComment rc : request.getRequestComments())
|
193 |
|
|
comments.add(rc.getComment());
|
194 |
|
|
CommentsInfo commentsInfo = new CommentsInfo(comments);
|
195 |
38818
|
stefania.m
|
commentsInfo.addStyleName("requestComments");
|
196 |
|
|
requestInfoPanel.add(commentsInfo.asWidget());
|
197 |
|
|
}
|
198 |
|
|
|
199 |
45767
|
panagiotis
|
if(!request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PAID)) {
|
200 |
41226
|
stefania.m
|
actionButtons.add(goToFundingWizard);
|
201 |
38818
|
stefania.m
|
}
|
202 |
41226
|
stefania.m
|
actionButtons.add(addDOI);
|
203 |
|
|
requestInfoPanel.add(actionButtons);
|
204 |
35839
|
stefania.m
|
}
|
205 |
35691
|
stefania.m
|
}
|
206 |
|
|
|
207 |
|
|
@Override
|
208 |
|
|
public Widget asWidget() {
|
209 |
|
|
return requestInfoPanel;
|
210 |
|
|
}
|
211 |
41226
|
stefania.m
|
|
212 |
|
|
public interface PublicationUpdatedListener {
|
213 |
|
|
void publicationUpdated();
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
public void setPublicationUpdatedListener(PublicationUpdatedListener publicationUpdatedListener) {
|
217 |
|
|
this.publicationUpdatedListener = publicationUpdatedListener;
|
218 |
|
|
}
|
219 |
35691
|
stefania.m
|
}
|