Revision 33291
Added by Nikon Gasparis over 9 years ago
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-madgik-validator/trunk", |
|
5 |
"deploy_repository": "dnet4-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr, nikonas@di.uoa.gr", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", |
|
9 |
"name": "uoa-madgik-validator" |
|
10 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/FetchValidationErrors.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.apache.struts2.interceptor.RequestAware; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class FetchValidationErrors extends BaseValidatorAction implements RequestAware { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -6630957729077819377L; |
|
16 |
private int ruleId; |
|
17 |
private int jobId; |
|
18 |
private String urlPrefix; |
|
19 |
private List<String> valErrors; |
|
20 |
private Logger logger = Logger.getLogger( FetchValidationErrors.class); |
|
21 |
|
|
22 |
public String execute() throws Exception { |
|
23 |
logger.debug("fetching val errors"); |
|
24 |
this.clearErrorsAndMessages(); |
|
25 |
valErrors = this.getOpenAIREValidator().getValidationErrors(jobId, ruleId); |
|
26 |
|
|
27 |
request.put("jsonization", jsonise(valErrors)); |
|
28 |
|
|
29 |
return Action.SUCCESS; |
|
30 |
} |
|
31 |
|
|
32 |
private String jsonise(List<String> errors) { |
|
33 |
StringBuilder sb = new StringBuilder(); |
|
34 |
sb.append("{\"errors\":["); |
|
35 |
|
|
36 |
for (int i=0; i < errors.size(); i++) { |
|
37 |
if (i > 0) |
|
38 |
sb.append(", "); |
|
39 |
|
|
40 |
if (errors.get(i) == null){ |
|
41 |
sb.append("{\"description\":").append("\"No record available\""); |
|
42 |
sb.append(", \"url\":\"").append("#").append("\""); |
|
43 |
|
|
44 |
} else { |
|
45 |
sb.append("{\"description\":\"").append(errors.get(i)).append("\""); |
|
46 |
sb.append(", \"url\":\"").append(createUrls(errors.get(i))).append("\""); |
|
47 |
} |
|
48 |
|
|
49 |
sb.append("}"); |
|
50 |
} |
|
51 |
|
|
52 |
sb.append("]}"); |
|
53 |
|
|
54 |
return sb.toString(); |
|
55 |
} |
|
56 |
|
|
57 |
private String createUrls(String label){ |
|
58 |
StringBuilder sb = new StringBuilder(); |
|
59 |
sb.append(urlPrefix).append(label); |
|
60 |
return sb.toString(); |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
public int getRuleId() { |
|
65 |
return ruleId; |
|
66 |
} |
|
67 |
|
|
68 |
public void setRuleId(int ruleId) { |
|
69 |
this.ruleId = ruleId; |
|
70 |
} |
|
71 |
|
|
72 |
public int getJobId() { |
|
73 |
return jobId; |
|
74 |
} |
|
75 |
|
|
76 |
public void setJobId(int jobId) { |
|
77 |
this.jobId = jobId; |
|
78 |
} |
|
79 |
|
|
80 |
public List<String> getValErrors() { |
|
81 |
return valErrors; |
|
82 |
} |
|
83 |
|
|
84 |
public void setValErrors(List<String> valErrors) { |
|
85 |
this.valErrors = valErrors; |
|
86 |
} |
|
87 |
|
|
88 |
public void setUrlPrefix(String urlPrefix) { |
|
89 |
this.urlPrefix = urlPrefix; |
|
90 |
} |
|
91 |
|
|
92 |
public String getUrlPrefix() { |
|
93 |
return urlPrefix; |
|
94 |
} |
|
95 |
|
|
96 |
private Map<String, Object> request; |
|
97 |
@Override |
|
98 |
public void setRequest(Map<String, Object> request) { |
|
99 |
this.request = request; |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/DatabaseCurator.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.text.ParseException; |
|
7 |
import java.text.SimpleDateFormat; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class DatabaseCurator extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -1868055729316139461L; |
|
16 |
private static final Logger logger = Logger.getLogger(DatabaseCurator.class); |
|
17 |
private String inDate = null; |
|
18 |
private String mode; |
|
19 |
|
|
20 |
public String getMode() { |
|
21 |
return mode; |
|
22 |
} |
|
23 |
|
|
24 |
|
|
25 |
public void setMode(String mode) { |
|
26 |
this.mode = mode; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
public String execute() { |
|
31 |
this.clearErrorsAndMessages(); |
|
32 |
|
|
33 |
try { |
|
34 |
this.getOpenAIREValidator().deleteOldJobs(inDate,mode); |
|
35 |
} catch (OpenAIREValidatorException e) { |
|
36 |
logger.error("Error deleting old jobs", e); |
|
37 |
this.addActionError(this.getText("generic.error")); |
|
38 |
reportException(e); |
|
39 |
return "input-problem"; |
|
40 |
} |
|
41 |
|
|
42 |
return Action.SUCCESS; |
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 |
public void validate() { |
|
47 |
this.clearErrors(); |
|
48 |
if (!mode.equalsIgnoreCase("uncompleted_only")){ |
|
49 |
if (inDate == null) { |
|
50 |
this.addActionError(this.getText("wrongFieldValue")); |
|
51 |
return; |
|
52 |
} |
|
53 |
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
54 |
if (inDate.trim().length() != dateFormat.toPattern().length()) { |
|
55 |
this.addActionError(this.getText("wrongFieldValue")); |
|
56 |
return; |
|
57 |
} |
|
58 |
dateFormat.setLenient(false); |
|
59 |
try { |
|
60 |
dateFormat.parse(inDate.trim()); |
|
61 |
} catch (ParseException pe) { |
|
62 |
this.addActionError(this.getText("wrongFieldValue")); |
|
63 |
return; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public String getInDate() { |
|
69 |
return inDate; |
|
70 |
} |
|
71 |
|
|
72 |
public void setInDate(String inDate) { |
|
73 |
this.inDate = inDate; |
|
74 |
} |
|
75 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/PrepareJobBrowsing.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
6 |
|
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.apache.struts2.interceptor.SessionAware; |
|
12 |
|
|
13 |
import com.opensymphony.xwork2.Action; |
|
14 |
|
|
15 |
public class PrepareJobBrowsing extends BaseValidatorAction implements SessionAware { |
|
16 |
|
|
17 |
private static final long serialVersionUID = 7391643068980907156L; |
|
18 |
private Logger logger = Logger.getLogger(PrepareJobBrowsing.class); |
|
19 |
|
|
20 |
private boolean enableCuration = false; |
|
21 |
private Map<String,List<JobSubmitted>> jobs; |
|
22 |
|
|
23 |
private Map<String, Object> session; |
|
24 |
|
|
25 |
public String execute() { |
|
26 |
this.clearErrorsAndMessages(); |
|
27 |
try { |
|
28 |
logger.debug("preparing job browsing"); |
|
29 |
jobs = this.getOpenAIREValidator().getJobsOfUser((String) session.get(Constants.loggedInField)); |
|
30 |
enableCuration = getOpenAIREValidator().userOverridesRepoRegistration((String) session.get(Constants.loggedInField)); |
|
31 |
return Action.SUCCESS; |
|
32 |
} catch (Exception e) { |
|
33 |
logger.error("error while preparing job browsing", e); |
|
34 |
this.addActionError(this.getText("generic.error")); |
|
35 |
reportException(e); |
|
36 |
return "exception"; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public void setSession(Map<String, Object> session) { |
|
42 |
this.session = session; |
|
43 |
} |
|
44 |
|
|
45 |
public void setEnableCuration(boolean enableCuration) { |
|
46 |
this.enableCuration = enableCuration; |
|
47 |
} |
|
48 |
|
|
49 |
public boolean isEnableCuration() { |
|
50 |
return enableCuration; |
|
51 |
} |
|
52 |
|
|
53 |
public Map<String, List<JobSubmitted>> getJobs() { |
|
54 |
return jobs; |
|
55 |
} |
|
56 |
|
|
57 |
public void setJobs(Map<String, List<JobSubmitted>> jobs) { |
|
58 |
this.jobs = jobs; |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/PrepareSummary.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validator.dao.Entry; |
|
5 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
6 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import java.io.FileOutputStream; |
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.apache.poi.ss.usermodel.Cell; |
|
14 |
import org.apache.poi.ss.usermodel.Row; |
|
15 |
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
16 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
17 |
|
|
18 |
import com.opensymphony.xwork2.Action; |
|
19 |
|
|
20 |
public class PrepareSummary extends BaseValidatorAction { |
|
21 |
private static final long serialVersionUID = -462318678652799883L; |
|
22 |
private String jobId, groupBy; |
|
23 |
private JobSubmitted job; |
|
24 |
private List<Entry> entries; |
|
25 |
private String urlPrefix = null; |
|
26 |
private String errorMessage = ""; |
|
27 |
private String errorMessage0 = ""; |
|
28 |
private List<String> groupBy_values; |
|
29 |
private String filteredScore; |
|
30 |
private static final Logger logger = Logger.getLogger(PrepareSummary.class); |
|
31 |
|
|
32 |
public String execute() { |
|
33 |
this.clearErrorsAndMessages(); |
|
34 |
errorMessage = ""; |
|
35 |
try { |
|
36 |
logger.debug("preparing job summary for job "+jobId); |
|
37 |
entries = this.getOpenAIREValidator().getJobSummary(jobId,groupBy); |
|
38 |
groupBy_values = this.getOpenAIREValidator().getDistinctGroupByValues(jobId); |
|
39 |
filteredScore = this.getOpenAIREValidator().getFilteredScore(jobId, groupBy); |
|
40 |
job = this.getOpenAIREValidator().getJobSubmitted(jobId); |
|
41 |
// this.writeExcelDemo(); |
|
42 |
|
|
43 |
// String mtdPrfx = "oai_dc"; |
|
44 |
// logger.debug("set of job: "+job.getSet()); |
|
45 |
// if (job.getSet()!=null && job.getSet().equalsIgnoreCase("openaire_data")) |
|
46 |
// mtdPrfx = "oai_datacite";\ |
|
47 |
|
|
48 |
urlPrefix = job.getRepo() + "?verb=GetRecord&metadataPrefix=" + job.getMetadata_prefix() +"&identifier="; |
|
49 |
|
|
50 |
|
|
51 |
if(entries == null || entries.size() == 0) { |
|
52 |
errorMessage=job.getError(); |
|
53 |
errorMessage0 = getText("job.noTasks"); |
|
54 |
} |
|
55 |
|
|
56 |
; |
|
57 |
return Action.SUCCESS; |
|
58 |
} |
|
59 |
catch(Exception e) { |
|
60 |
logger.error("Error redirecting to job", e); |
|
61 |
this.addActionError(this.getText("generic.error")); |
|
62 |
reportException(e); |
|
63 |
return "exception"; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
private void writeExcelDemo() throws OpenAIREValidatorException { |
|
68 |
//Blank workbook |
|
69 |
XSSFWorkbook workbook = new XSSFWorkbook(); |
|
70 |
|
|
71 |
//Create a blank sheet |
|
72 |
XSSFSheet sheet = workbook.createSheet("Datacite Report"); |
|
73 |
|
|
74 |
int rownum = 0; |
|
75 |
Row row = sheet.createRow(rownum++); |
|
76 |
Cell cell = row.createCell(0); |
|
77 |
cell.setCellValue("Reponame"); |
|
78 |
cell = row.createCell(1); |
|
79 |
cell.setCellValue("Rule name"); |
|
80 |
// cell = row.createCell(2); |
|
81 |
// cell.setCellValue("Rule Desc"); |
|
82 |
cell = row.createCell(2); |
|
83 |
cell.setCellValue("# of records tested"); |
|
84 |
cell = row.createCell(3); |
|
85 |
cell.setCellValue("# of records failed"); |
|
86 |
cell = row.createCell(4); |
|
87 |
cell.setCellValue("FAIL/SUCCESS"); |
|
88 |
|
|
89 |
for (String groupBy : groupBy_values) { |
|
90 |
entries = this.getOpenAIREValidator().getJobSummary(jobId,groupBy); |
|
91 |
filteredScore = this.getOpenAIREValidator().getFilteredScore(jobId, groupBy); |
|
92 |
for (Entry entry : entries) { |
|
93 |
row = sheet.createRow(rownum++); |
|
94 |
cell = row.createCell(0); |
|
95 |
cell.setCellValue(groupBy); |
|
96 |
cell = row.createCell(1); |
|
97 |
cell.setCellValue(entry.getName()); |
|
98 |
// cell = row.createCell(2); |
|
99 |
// cell.setCellValue(entry.getDescription()); |
|
100 |
cell = row.createCell(2); |
|
101 |
cell.setCellValue(Integer.parseInt(entry.getSuccesses().split("/")[1])); |
|
102 |
cell = row.createCell(3); |
|
103 |
cell.setCellValue(Integer.parseInt(entry.getSuccesses().split("/")[0])); |
|
104 |
cell = row.createCell(4); |
|
105 |
if (Integer.parseInt(entry.getSuccesses().split("/")[1]) == Integer.parseInt(entry.getSuccesses().split("/")[0])) |
|
106 |
cell.setCellValue("SUCCESS"); |
|
107 |
else |
|
108 |
cell.setCellValue("FAIL"); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
try |
|
113 |
{ |
|
114 |
//Write the workbook in file system |
|
115 |
FileOutputStream out = new FileOutputStream(new File("datacite_full.xlsx")); |
|
116 |
workbook.write(out); |
|
117 |
out.close(); |
|
118 |
System.out.println("howtodoinjava_demo.xlsx written successfully on disk."); |
|
119 |
} |
|
120 |
catch (Exception e) |
|
121 |
{ |
|
122 |
e.printStackTrace(); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
public String getUrlPrefix() { |
|
127 |
return urlPrefix; |
|
128 |
} |
|
129 |
|
|
130 |
public void setUrlPrefix(String urlPrefix) { |
|
131 |
this.urlPrefix = urlPrefix; |
|
132 |
} |
|
133 |
|
|
134 |
public String getJobId() { |
|
135 |
return jobId; |
|
136 |
} |
|
137 |
|
|
138 |
public void setJobId(String jobId) { |
|
139 |
this.jobId = jobId; |
|
140 |
} |
|
141 |
|
|
142 |
public JobSubmitted getJob() { |
|
143 |
return job; |
|
144 |
} |
|
145 |
|
|
146 |
public void setJob(JobSubmitted job) { |
|
147 |
this.job = job; |
|
148 |
} |
|
149 |
|
|
150 |
public List<Entry> getEntries() { |
|
151 |
return entries; |
|
152 |
} |
|
153 |
|
|
154 |
public void setEntries(List<Entry> entries) { |
|
155 |
this.entries = entries; |
|
156 |
} |
|
157 |
|
|
158 |
public String getGroupBy() { |
|
159 |
return groupBy; |
|
160 |
} |
|
161 |
|
|
162 |
public void setGroupBy(String groupBy) { |
|
163 |
this.groupBy = groupBy; |
|
164 |
} |
|
165 |
|
|
166 |
public List<String> getGroupBy_values() { |
|
167 |
return groupBy_values; |
|
168 |
} |
|
169 |
|
|
170 |
public void setGroupBy_values(List<String> groupBy_values) { |
|
171 |
this.groupBy_values = groupBy_values; |
|
172 |
} |
|
173 |
|
|
174 |
public void setErrorMessage(String errorMessage) { |
|
175 |
this.errorMessage = errorMessage; |
|
176 |
} |
|
177 |
|
|
178 |
public String getErrorMessage() { |
|
179 |
return errorMessage; |
|
180 |
} |
|
181 |
|
|
182 |
public String getFilteredScore() { |
|
183 |
return filteredScore; |
|
184 |
} |
|
185 |
|
|
186 |
public void setFilteredScore(String filteredScore) { |
|
187 |
this.filteredScore = filteredScore; |
|
188 |
} |
|
189 |
|
|
190 |
public String getErrorMessage0() { |
|
191 |
return errorMessage0; |
|
192 |
} |
|
193 |
|
|
194 |
public void setErrorMessage0(String errorMessage0) { |
|
195 |
this.errorMessage0 = errorMessage0; |
|
196 |
} |
|
197 |
|
|
198 |
|
|
199 |
} |
|
200 |
|
|
201 |
////This data needs to be written (Object[]) |
|
202 |
//Map<String, Object[]> data = new TreeMap<String, Object[]>(); |
|
203 |
////Reponame | #of records tested |Rule name | Rule Desc | FAIL/SUCCESS | # of records failed |
|
204 |
//data.put("1", new Object[] {"Reponame", "NAME", "LASTNAME"}); |
|
205 |
//data.put("2", new Object[] {1, "Amit", "Shukla"}); |
|
206 |
//data.put("3", new Object[] {2, "Lokesh", "Gupta"}); |
|
207 |
//data.put("4", new Object[] {3, "John", "Adwards"}); |
|
208 |
//data.put("5", new Object[] {4, "Brian", "Schultz"}); |
|
209 |
// |
|
210 |
////Iterate over data and write to sheet |
|
211 |
//Set<String> keyset = data.keySet(); |
|
212 |
//int rownum = 0; |
|
213 |
//for (String key : keyset) |
|
214 |
//{ |
|
215 |
// Row row = sheet.createRow(rownum++); |
|
216 |
// Object [] objArr = data.get(key); |
|
217 |
// int cellnum = 0; |
|
218 |
// for (Object obj : objArr) |
|
219 |
// { |
|
220 |
// Cell cell = row.createCell(cellnum++); |
|
221 |
// if(obj instanceof String) |
|
222 |
// cell.setCellValue((String)obj); |
|
223 |
// else if(obj instanceof Integer) |
|
224 |
// cell.setCellValue((Integer)obj); |
|
225 |
// } |
|
226 |
//} |
|
227 |
|
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/BugReporter.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions; |
|
2 |
|
|
3 |
|
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.apache.log4j.Logger; |
|
8 |
|
|
9 |
import com.opensymphony.xwork2.Action; |
|
10 |
|
|
11 |
public class BugReporter extends BaseValidatorAction { |
|
12 |
|
|
13 |
private static final long serialVersionUID = -3331529072364646515L; |
|
14 |
|
|
15 |
private transient Logger logger = Logger.getLogger(BugReporter.class); |
|
16 |
|
|
17 |
private String ex = null; |
|
18 |
|
|
19 |
public String execute() { |
|
20 |
List<String> recipients = new ArrayList<String>(); |
|
21 |
this.addActionError(this.getText("generic.error")); |
|
22 |
try { |
|
23 |
recipients.add(this.getValAdminEmail()); |
|
24 |
String message = "An exception has occurred:\n"+ex; |
|
25 |
String subject = "Automatic Bug Report"; |
|
26 |
this.getEmailer().sendMail(recipients, subject, message, false, null); |
|
27 |
} catch (Exception e) { |
|
28 |
logger.error("error sending error report", e); |
|
29 |
} |
|
30 |
return Action.SUCCESS; |
|
31 |
} |
|
32 |
|
|
33 |
public void setEx(String ex) { |
|
34 |
this.ex = ex; |
|
35 |
} |
|
36 |
|
|
37 |
public String getEx() { |
|
38 |
return ex; |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/users/EditUser.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.user.UserProfileIS; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
6 |
|
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
import org.apache.struts2.interceptor.SessionAware; |
|
11 |
|
|
12 |
import com.opensymphony.xwork2.Action; |
|
13 |
|
|
14 |
public class EditUser extends BaseValidatorAction implements SessionAware { |
|
15 |
|
|
16 |
private static final long serialVersionUID = -362061491263257713L; |
|
17 |
private Logger logger = Logger.getLogger(EditUser.class); |
|
18 |
|
|
19 |
private String fname, lname, inst; |
|
20 |
|
|
21 |
public String getFname() { |
|
22 |
return fname; |
|
23 |
} |
|
24 |
|
|
25 |
public void setFname(String fname) { |
|
26 |
this.fname = fname; |
|
27 |
} |
|
28 |
|
|
29 |
public String getLname() { |
|
30 |
return lname; |
|
31 |
} |
|
32 |
|
|
33 |
public void setLname(String lname) { |
|
34 |
this.lname = lname; |
|
35 |
} |
|
36 |
|
|
37 |
public String getInst() { |
|
38 |
return inst; |
|
39 |
} |
|
40 |
|
|
41 |
public void setInst(String inst) { |
|
42 |
this.inst = inst; |
|
43 |
} |
|
44 |
|
|
45 |
private Map<String, Object> session; |
|
46 |
|
|
47 |
public String execute() { |
|
48 |
this.clearErrorsAndMessages(); |
|
49 |
try { |
|
50 |
logger.debug("getting for edit user " + (String) session.get(Constants.loggedInField)); |
|
51 |
// if (isModeLdap() || isModeOpenAIRE()) { |
|
52 |
if (isModeLdap()) { |
|
53 |
UserProfileIS profile = (UserProfileIS) this.getUserAPI().getUser((String) session.get(Constants.loggedInField)); |
|
54 |
fname = profile.getFname(); |
|
55 |
lname = profile.getLname(); |
|
56 |
inst = profile.getInstitution(); |
|
57 |
} |
|
58 |
return Action.SUCCESS; |
|
59 |
} catch (Exception e) { |
|
60 |
logger.error("error getting for edit user " + (String) session.get(Constants.loggedInField), e); |
|
61 |
this.addActionError(this.getText("generic.error")); |
|
62 |
reportException(e); |
|
63 |
return "exception"; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
public String edit() { |
|
68 |
this.clearErrorsAndMessages(); |
|
69 |
try { |
|
70 |
logger.debug("editing user " + (String) session.get(Constants.loggedInField)); |
|
71 |
this.getUserAPI().editUser((String) session.get(Constants.loggedInField), fname, lname, inst); |
|
72 |
this.addActionMessage(this.getText("editUser.success")); |
|
73 |
return Action.SUCCESS; |
|
74 |
} catch (Exception e) { |
|
75 |
logger.error("error editing user " + (String) session.get(Constants.loggedInField), e); |
|
76 |
this.addActionError(this.getText("generic.error")); |
|
77 |
reportException(e); |
|
78 |
return "exception"; |
|
79 |
} |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void setSession(Map<String, Object> session) { |
|
85 |
this.session = session; |
|
86 |
} |
|
87 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/users/Register.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.regex.Pattern; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
11 |
|
|
12 |
public class Register extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 4906485913149844710L; |
|
15 |
private Logger logger = Logger.getLogger(Register.class); |
|
16 |
|
|
17 |
private String email, password, repassword; |
|
18 |
private String username, firstName, lastName; |
|
19 |
|
|
20 |
public String execute() { |
|
21 |
this.clearErrorsAndMessages(); |
|
22 |
try { |
|
23 |
logger.debug("registering user " + email); |
|
24 |
String activationId = null; |
|
25 |
|
|
26 |
if (isModeLdap() || isModeOpenAIRE()) |
|
27 |
activationId = this.getUserAPI().addUser(username, email, password, firstName, lastName); |
|
28 |
else |
|
29 |
activationId = this.getUserAPI().addUser(this.getEmail(), this.getPassword()); |
|
30 |
|
|
31 |
this.addActionMessage((this.getText("registration.successful"))); |
|
32 |
this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom())); |
|
33 |
|
|
34 |
ArrayList<String> to = new ArrayList<String>(); |
|
35 |
to.add(this.getEmail()); |
|
36 |
|
|
37 |
this.getEmailer().sendMail(to, this.getText("registration.mail.subject"), this.getText("registration.mail.message") + ": " + this.getValBaseUrl() + "/activateAccount.action?activationId=" + activationId, false, null); |
|
38 |
|
|
39 |
return Action.SUCCESS; |
|
40 |
} catch (Exception e) { |
|
41 |
logger.error("error registering user " + email, e); |
|
42 |
this.addActionError(this.getText("generic.error")); |
|
43 |
reportException(e); |
|
44 |
return "exception"; |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public void validate() { |
|
49 |
this.clearErrors(); |
|
50 |
if (this.getEmail() == null || this.getEmail().length() == 0) |
|
51 |
this.addFieldError("email", this.getText("compulsoryField")); |
|
52 |
if (this.getPassword() == null || this.getPassword().length() == 0) |
|
53 |
this.addFieldError("password", this.getText("compulsoryField")); |
|
54 |
if (this.getRepassword() == null || this.getRepassword().length() == 0) |
|
55 |
this.addFieldError("repassword", this.getText("compulsoryField")); |
|
56 |
|
|
57 |
if (isModeLdap()) { |
|
58 |
if (this.getUsername() == null || this.getUsername().length() == 0) |
|
59 |
this.addFieldError("username", this.getText("compulsoryField")); |
|
60 |
if (this.getFirstName() == null || this.getFirstName().length() == 0) |
|
61 |
this.addFieldError("firstName", this.getText("compulsoryField")); |
|
62 |
if (this.getLastName() == null || this.getLastName().length() == 0) |
|
63 |
this.addFieldError("lastName", this.getText("compulsoryField")); |
|
64 |
} |
|
65 |
|
|
66 |
if (!this.getPassword().equals(this.getRepassword())) |
|
67 |
this.addFieldError("password", this.getText("identicalPasswords")); |
|
68 |
|
|
69 |
Pattern rfc2822 = Pattern.compile("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"); |
|
70 |
if (!rfc2822.matcher(this.getEmail().trim().toLowerCase()).matches()) { |
|
71 |
this.addFieldError("email", this.getText("notValidEmail")); |
|
72 |
} |
|
73 |
|
|
74 |
try { |
|
75 |
if (this.getUserAPI().userExists(this.getEmail())) |
|
76 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
77 |
if (isModeLdap() && this.getUserAPI().usernameExists(this.getUsername())) |
|
78 |
this.addFieldError("username", this.getText("userAlreadyExists")); |
|
79 |
|
|
80 |
} catch (Exception e) { |
|
81 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
public String getEmail() { |
|
86 |
return email; |
|
87 |
} |
|
88 |
|
|
89 |
public void setEmail(String email) { |
|
90 |
this.email = email; |
|
91 |
} |
|
92 |
|
|
93 |
public String getPassword() { |
|
94 |
return password; |
|
95 |
} |
|
96 |
|
|
97 |
public void setPassword(String password) { |
|
98 |
this.password = password; |
|
99 |
} |
|
100 |
|
|
101 |
public String getRepassword() { |
|
102 |
return repassword; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRepassword(String repassword) { |
|
106 |
this.repassword = repassword; |
|
107 |
} |
|
108 |
|
|
109 |
public String getUsername() { |
|
110 |
return username; |
|
111 |
} |
|
112 |
|
|
113 |
public void setUsername(String username) { |
|
114 |
this.username = username; |
|
115 |
} |
|
116 |
|
|
117 |
public String getFirstName() { |
|
118 |
return firstName; |
|
119 |
} |
|
120 |
|
|
121 |
public void setFirstName(String firstName) { |
|
122 |
this.firstName = firstName; |
|
123 |
} |
|
124 |
|
|
125 |
public String getLastName() { |
|
126 |
return lastName; |
|
127 |
} |
|
128 |
|
|
129 |
public void setLastName(String lastName) { |
|
130 |
this.lastName = lastName; |
|
131 |
} |
|
132 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/users/ActivateAccount.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class ActivateAccount extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 4680016183168923054L; |
|
12 |
private Logger logger = Logger.getLogger(ActivateAccount.class); |
|
13 |
|
|
14 |
private String activationId; |
|
15 |
|
|
16 |
public String execute() { |
|
17 |
this.clearErrorsAndMessages(); |
|
18 |
try { |
|
19 |
logger.debug("activating user account with activation id " + activationId); |
|
20 |
if (this.getUserAPI().activateUser(this.getActivationId())) |
|
21 |
this.addActionMessage(this.getText("registration.okAccountActivation")); |
|
22 |
else |
|
23 |
this.addActionMessage(this.getText("registration.okAccountAlreadyActivation")); |
|
24 |
return Action.SUCCESS; |
|
25 |
} catch (Exception e) { |
|
26 |
logger.error("error activating user account with activation id " + activationId, e); |
|
27 |
this.addActionError(this.getText("generic.error")); |
|
28 |
reportException(e); |
|
29 |
return "exception"; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
public void validate() { |
|
34 |
this.clearErrors(); |
|
35 |
if (this.getActivationId() == null || this.getActivationId().length() == 0) { |
|
36 |
this.addActionError(this.getText("noActivationId")); |
|
37 |
return; |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public String getActivationId() { |
|
42 |
return activationId; |
|
43 |
} |
|
44 |
|
|
45 |
public void setActivationId(String activationId) { |
|
46 |
this.activationId = activationId; |
|
47 |
} |
|
48 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/feedback/FeedBackPage.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.feedback; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
@SuppressWarnings("serial") |
|
6 |
public class FeedBackPage extends BaseValidatorAction{ |
|
7 |
|
|
8 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/feedback/SendFeedback.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.feedback; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.apache.struts2.interceptor.SessionAware; |
|
12 |
|
|
13 |
import com.opensymphony.xwork2.Action; |
|
14 |
|
|
15 |
public class SendFeedback extends BaseValidatorAction implements SessionAware { |
|
16 |
|
|
17 |
private static final long serialVersionUID = -4610293868659763433L; |
|
18 |
private Logger logger = Logger.getLogger(SendFeedback.class); |
|
19 |
|
|
20 |
private String reason, message; |
|
21 |
private Map<String, Object> session; |
|
22 |
|
|
23 |
public String execute() { |
|
24 |
this.clearErrorsAndMessages(); |
|
25 |
try { |
|
26 |
logger.debug("sending feedback from user " + (String) session.get(Constants.loggedInField)); |
|
27 |
List<String> recipients = new ArrayList<String>(); |
|
28 |
recipients.add(this.getValAdminEmail()); |
|
29 |
String message = "The following message was sent from " + (String) session.get(Constants.loggedInField) + "\n\n" + this.message; |
|
30 |
String subject = this.reason; |
|
31 |
this.getEmailer().sendMail(recipients, subject, message, false, null); |
|
32 |
this.addActionMessage(this.getText("feedback.success")); |
|
33 |
return Action.SUCCESS; |
|
34 |
} catch (Exception e) { |
|
35 |
logger.error("error sending feedback", e); |
|
36 |
this.addActionError(this.getText("generic.error")); |
|
37 |
reportException(e); |
|
38 |
return "exception"; |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void setSession(Map<String, Object> session) { |
|
44 |
this.session = session; |
|
45 |
} |
|
46 |
|
|
47 |
public String getReason() { |
|
48 |
return reason; |
|
49 |
} |
|
50 |
|
|
51 |
public void setReason(String reason) { |
|
52 |
this.reason = reason; |
|
53 |
} |
|
54 |
|
|
55 |
public String getMessage() { |
|
56 |
return message; |
|
57 |
} |
|
58 |
|
|
59 |
public void setMessage(String message) { |
|
60 |
this.message = message; |
|
61 |
} |
|
62 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/DeleteRuleSet.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class DeleteRuleSet extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 4858147485197818532L; |
|
12 |
private int setId; |
|
13 |
private static final Logger logger = Logger.getLogger(DeleteRuleSet.class); |
|
14 |
|
|
15 |
public int getSetId() { |
|
16 |
return setId; |
|
17 |
} |
|
18 |
|
|
19 |
public void setSetId(int setId) { |
|
20 |
this.setId = setId; |
|
21 |
} |
|
22 |
|
|
23 |
public String execute() { |
|
24 |
this.clearErrorsAndMessages(); |
|
25 |
try { |
|
26 |
logger.debug("deleting rule set "+setId); |
|
27 |
this.getOpenAIREValidator().deleteRuleSet(setId); |
|
28 |
this.addActionMessage(this.getText("deleteRuleSet.success")); |
|
29 |
return Action.SUCCESS; |
|
30 |
} |
|
31 |
catch(Exception e) { |
|
32 |
logger.error("Error deleting ruleset", e); |
|
33 |
this.addActionError(this.getText("generic.error")); |
|
34 |
reportException(e); |
|
35 |
return "exception"; |
|
36 |
} |
|
37 |
} |
|
38 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/GetRuleSets.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.RuleSet; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
11 |
|
|
12 |
public class GetRuleSets extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = -5220242100308666597L; |
|
15 |
private List<RuleSet> sets; |
|
16 |
private static final Logger logger = Logger.getLogger(GetRuleSets.class); |
|
17 |
|
|
18 |
public List<RuleSet> getSets() { |
|
19 |
return sets; |
|
20 |
} |
|
21 |
|
|
22 |
public void setSets(List<RuleSet> sets) { |
|
23 |
this.sets = sets; |
|
24 |
} |
|
25 |
|
|
26 |
public String execute() throws Exception { |
|
27 |
this.clearErrorsAndMessages(); |
|
28 |
try { |
|
29 |
logger.debug("getting all rule sets"); |
|
30 |
sets = this.getOpenAIREValidator().getRuleSets(); |
|
31 |
return Action.SUCCESS; |
|
32 |
} catch (Exception e) { |
|
33 |
logger.error("Error getting rule sets", e); |
|
34 |
this.addActionError(this.getText("generic.error")); |
|
35 |
reportException(e); |
|
36 |
return "exception"; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/CreateRuleSet.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class CreateRuleSet extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 5623461974078831740L; |
|
12 |
|
|
13 |
private String[] chosenContentRules = null; |
|
14 |
private String[] chosenUsageRules = null; |
|
15 |
private String name = null; |
|
16 |
private String shortName = null; |
|
17 |
private String description = null; |
|
18 |
private String guidelinesAcronym = null; |
|
19 |
private String visibility = null; |
|
20 |
private String funct = null; |
|
21 |
private int setId = -1; |
|
22 |
private static final Logger logger = Logger.getLogger(CreateRuleSet.class); |
|
23 |
|
|
24 |
public String execute() { |
|
25 |
this.clearErrorsAndMessages(); |
|
26 |
try { |
|
27 |
logger.debug("creating a new rule set "+name); |
|
28 |
if(funct.equals("create")) { |
|
29 |
this.getOpenAIREValidator().createRuleSet(name, shortName, description, guidelinesAcronym, visibility, chosenContentRules,chosenUsageRules); |
|
30 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
31 |
} |
|
32 |
else if(funct.equals("edit")) { |
|
33 |
this.getOpenAIREValidator().editRuleSet(setId, name, shortName, description, guidelinesAcronym, visibility, chosenContentRules,chosenUsageRules); |
|
34 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
35 |
} |
|
36 |
return Action.SUCCESS; |
|
37 |
} |
|
38 |
catch(Exception e) { |
|
39 |
logger.error("Error creating/editing ruleset", e); |
|
40 |
this.addActionError(this.getText("generic.error")); |
|
41 |
reportException(e); |
|
42 |
return "exception"; |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
public void validate() { |
|
47 |
this.clearErrors(); |
|
48 |
if((chosenContentRules == null || chosenContentRules.length < 1)||(chosenUsageRules == null || chosenUsageRules.length < 1)) |
|
49 |
this.addActionError(this.getText("createRuleSets.atLeastOneRule")); |
|
50 |
if(funct == null) |
|
51 |
this.addActionError(this.getText("uknownError")); |
|
52 |
} |
|
53 |
public String getDescription() { |
|
54 |
return description; |
|
55 |
} |
|
56 |
public void setDescription(String description) { |
|
57 |
this.description = description; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
public int getSetId() { |
|
62 |
return setId; |
|
63 |
} |
|
64 |
public void setSetId(int setId) { |
|
65 |
this.setId = setId; |
|
66 |
} |
|
67 |
public String getFunct() { |
|
68 |
return funct; |
|
69 |
} |
|
70 |
public void setFunct(String funct) { |
|
71 |
this.funct = funct; |
|
72 |
} |
|
73 |
public String[] getChosenContentRules() { |
|
74 |
return chosenContentRules; |
|
75 |
} |
|
76 |
public void setChosenContentRules(String[] chosenContentRules) { |
|
77 |
this.chosenContentRules = chosenContentRules; |
|
78 |
} |
|
79 |
public String[] getChosenUsageRules() { |
|
80 |
return chosenUsageRules; |
|
81 |
} |
|
82 |
public void setChosenUsageRules(String[] chosenUsageRules) { |
|
83 |
this.chosenUsageRules = chosenUsageRules; |
|
84 |
} |
|
85 |
public String getName() { |
|
86 |
return name; |
|
87 |
} |
|
88 |
public void setName(String name) { |
|
89 |
this.name = name; |
|
90 |
} |
|
91 |
|
|
92 |
public String getVisibility() { |
|
93 |
return visibility; |
|
94 |
} |
|
95 |
|
|
96 |
public void setVisibility(String visibility) { |
|
97 |
this.visibility = visibility; |
|
98 |
} |
|
99 |
|
|
100 |
public String getGuidelinesAcronym() { |
|
101 |
return guidelinesAcronym; |
|
102 |
} |
|
103 |
|
|
104 |
public void setGuidelinesAcronym(String guidelinesAcronym) { |
|
105 |
this.guidelinesAcronym = guidelinesAcronym; |
|
106 |
} |
|
107 |
|
|
108 |
public String getShortName() { |
|
109 |
return shortName; |
|
110 |
} |
|
111 |
|
|
112 |
public void setShortName(String shortName) { |
|
113 |
this.shortName = shortName; |
|
114 |
} |
|
115 |
|
|
116 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/FetchRuleDescriptions.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
import gr.uoa.di.validatorweb.actions.compTest.RuleD; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class FetchRuleDescriptions extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -2095636309367991598L; |
|
16 |
private List<RuleD> rulesContent; |
|
17 |
private List<RuleD> rulesUsage; |
|
18 |
private String ruleSetDescription; |
|
19 |
private String ruleSetId; |
|
20 |
private static final Logger logger = Logger.getLogger(FetchRuleDescriptions.class); |
|
21 |
|
|
22 |
public String execute() { |
|
23 |
this.clearErrorsAndMessages(); |
|
24 |
|
|
25 |
String ruleSetName = null; |
|
26 |
List<String> ruleIdsContent = new ArrayList<String>(); |
|
27 |
List<String> ruleIdsUsage = new ArrayList<String>(); |
|
28 |
int id; |
|
29 |
|
|
30 |
try { |
|
31 |
id = Integer.parseInt(ruleSetId); |
|
32 |
|
|
33 |
} catch (NumberFormatException nfe) { |
|
34 |
// case of wrong url |
|
35 |
id = -1; |
|
36 |
} |
|
37 |
|
|
38 |
try { |
|
39 |
|
|
40 |
ruleSetName = this.getOpenAIREValidator().getRuleSetName(id); |
|
41 |
//case of wrong given id |
|
42 |
if (ruleSetName == null) { |
|
43 |
id = -1; |
|
44 |
} |
|
45 |
|
|
46 |
if (id == -1) { |
|
47 |
ruleSetName = "All"; |
|
48 |
ruleIdsContent = this.getOpenAIREValidator().getAllRuleIdsByJobType("content"); |
|
49 |
ruleIdsUsage = this.getOpenAIREValidator().getAllRuleIdsByJobType("usage"); |
|
50 |
|
|
51 |
} else { |
|
52 |
ruleSetName = this.getOpenAIREValidator().getRuleSetName(id); |
|
53 |
ruleIdsContent = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(id,"content"); |
|
54 |
ruleIdsUsage = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(id,"usage"); |
|
55 |
} |
|
56 |
|
|
57 |
rulesContent = this.getOpenAIREValidator().convertRuleIdsListToRuleDList(ruleIdsContent); |
|
58 |
rulesUsage = this.getOpenAIREValidator().convertRuleIdsListToRuleDList(ruleIdsUsage); |
|
59 |
|
|
60 |
ruleSetDescription = "ruleSetInfo."+ruleSetName; |
|
61 |
|
|
62 |
logger.debug("ruleset descr " + ruleSetDescription); |
|
63 |
logger.debug("rulesContent" + rulesContent.size()); |
|
64 |
logger.debug("rulesUsage" + rulesUsage.size()); |
|
65 |
|
|
66 |
return Action.SUCCESS; |
|
67 |
} |
|
68 |
catch(Exception e) { |
|
69 |
logger.error("Error fetching rule descriptions", e); |
|
70 |
this.addActionError(this.getText("generic.error")); |
|
71 |
reportException(e); |
|
72 |
return "exception"; |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
public List<RuleD> getRulesContent() { |
|
78 |
return rulesContent; |
|
79 |
} |
|
80 |
|
|
81 |
public void setRulesContent(List<RuleD> rulesContent) { |
|
82 |
this.rulesContent = rulesContent; |
|
83 |
} |
|
84 |
|
|
85 |
public List<RuleD> getRulesUsage() { |
|
86 |
return rulesUsage; |
|
87 |
} |
|
88 |
|
|
89 |
public void setRulesUsage(List<RuleD> rulesUsage) { |
|
90 |
this.rulesUsage = rulesUsage; |
|
91 |
} |
|
92 |
|
|
93 |
public void setRuleSetDescription(String ruleSetDescription) { |
|
94 |
this.ruleSetDescription = ruleSetDescription; |
|
95 |
} |
|
96 |
|
|
97 |
public String getRuleSetDescription() { |
|
98 |
return ruleSetDescription; |
|
99 |
} |
|
100 |
|
|
101 |
public String getRuleSetId() { |
|
102 |
return ruleSetId; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRuleSetId(String ruleSetId) { |
|
106 |
this.ruleSetId = ruleSetId; |
|
107 |
} |
|
108 |
} |
|
109 |
|
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/GetRules.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.RuleSet; |
|
4 |
import gr.uoa.di.validator.dao.Utilities; |
|
5 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
6 |
|
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
|
|
12 |
import com.opensymphony.xwork2.Action; |
|
13 |
|
|
14 |
public class GetRules extends BaseValidatorAction { |
|
15 |
|
|
16 |
private static final long serialVersionUID = 3336444896590055688L; |
|
17 |
private int setId = -1; |
|
18 |
private List<RuleS> rulesContent; |
|
19 |
private List<RuleS> rulesUsage; |
|
20 |
private List<String> ruleIdsContent; |
|
21 |
private List<String> ruleIdsUsage; |
|
22 |
private String funct = null; |
|
23 |
private String name = null; |
|
24 |
private String description = null; |
|
25 |
private String shortName = null; |
|
26 |
private String guidelinesAcronym = null; |
|
27 |
private String visibility = null; |
|
28 |
|
|
29 |
private static final Logger logger = Logger.getLogger(GetRules.class); |
|
30 |
|
|
31 |
public String execute() { |
|
32 |
this.clearErrorsAndMessages(); |
|
33 |
try { |
|
34 |
logger.debug("getting rules in rule set "+setId); |
|
35 |
if (setId == -1) { |
|
36 |
funct = "create"; |
|
37 |
ruleIdsContent = new ArrayList<String>(); |
|
38 |
rulesContent = this.getOpenAIREValidator().getAllRulesForPresentationByJobType("content"); |
|
39 |
ruleIdsUsage = new ArrayList<String>(); |
|
40 |
rulesUsage = this.getOpenAIREValidator().getAllRulesForPresentationByJobType("usage"); |
|
41 |
} else { |
|
42 |
funct = "edit"; |
|
43 |
ruleIdsContent = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(setId,"content"); |
|
44 |
rulesContent = this.getOpenAIREValidator().getAllRulesForPresentationByJobTypeByRuleSet(ruleIdsContent,"content"); |
|
45 |
ruleIdsUsage = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(setId,"usage"); |
|
46 |
rulesUsage = this.getOpenAIREValidator().getAllRulesForPresentationByJobTypeByRuleSet(ruleIdsContent,"usage"); |
|
47 |
RuleSet set = this.getOpenAIREValidator().getRuleSet(setId); |
|
48 |
name = set.getName(); |
|
49 |
description = set.getDescription(); |
|
50 |
guidelinesAcronym = set.getGuidelinesAcronym(); |
|
51 |
visibility = Utilities.convertListToString(set.getVisibility()); |
|
52 |
shortName= set.getShortName(); |
|
53 |
|
|
54 |
|
|
55 |
} |
|
56 |
return Action.SUCCESS; |
|
57 |
} |
|
58 |
catch(Exception e) { |
|
59 |
logger.error("Error getting rules", e); |
|
60 |
this.addActionError(this.getText("generic.error")); |
|
61 |
reportException(e); |
|
62 |
return "exception"; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
public String getDescription() { |
|
68 |
return description; |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
public void setDescription(String description) { |
|
73 |
this.description = description; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
public String getName() { |
|
78 |
return name; |
|
79 |
} |
|
80 |
|
|
81 |
public void setName(String name) { |
|
82 |
this.name = name; |
|
83 |
} |
|
84 |
|
|
85 |
public String getFunct() { |
|
86 |
return funct; |
|
87 |
} |
|
88 |
|
|
89 |
public void setFunct(String funct) { |
|
90 |
this.funct = funct; |
|
91 |
} |
|
92 |
|
|
93 |
public int getSetId() { |
|
94 |
return setId; |
|
95 |
} |
|
96 |
|
|
97 |
public void setSetId(int setId) { |
|
98 |
this.setId = setId; |
|
99 |
} |
|
100 |
|
|
101 |
public List<RuleS> getRulesContent() { |
|
102 |
return rulesContent; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRulesContent(List<RuleS> rulesContent) { |
|
106 |
this.rulesContent = rulesContent; |
|
107 |
} |
|
108 |
|
|
109 |
public List<RuleS> getRulesUsage() { |
|
110 |
return rulesUsage; |
|
111 |
} |
|
112 |
|
|
113 |
public void setRulesUsage(List<RuleS> rulesUsage) { |
|
114 |
this.rulesUsage = rulesUsage; |
|
115 |
} |
|
116 |
|
|
117 |
public List<String> getRuleIdsContent() { |
|
118 |
return ruleIdsContent; |
|
119 |
} |
|
120 |
|
|
121 |
public void setRuleIdsContent(List<String> ruleIdsContent) { |
|
122 |
this.ruleIdsContent = ruleIdsContent; |
|
123 |
} |
|
124 |
|
|
125 |
public List<String> getRuleIdsUsage() { |
|
126 |
return ruleIdsUsage; |
|
127 |
} |
|
128 |
|
|
129 |
public void setRuleIdsUsage(List<String> ruleIdsUsage) { |
|
130 |
this.ruleIdsUsage = ruleIdsUsage; |
|
131 |
} |
|
132 |
|
|
133 |
|
|
134 |
public String getGuidelinesAcronym() { |
|
135 |
return guidelinesAcronym; |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
public void setGuidelinesAcronym(String guidelinesAcronym) { |
|
140 |
this.guidelinesAcronym = guidelinesAcronym; |
|
141 |
} |
|
142 |
|
|
143 |
|
|
144 |
public String getVisibility() { |
|
145 |
return visibility; |
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
public void setVisibility(String visibility) { |
|
150 |
this.visibility = visibility; |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
public String getShortName() { |
|
155 |
return shortName; |
|
156 |
} |
|
157 |
|
|
158 |
|
|
159 |
public void setShortName(String shortName) { |
|
160 |
this.shortName = shortName; |
|
161 |
} |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
|
|
166 |
|
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/RuleS.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
public class RuleS { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String name; |
|
7 |
private boolean chosen = false; |
|
8 |
|
|
9 |
|
|
10 |
public String getId() { |
|
11 |
return id; |
|
12 |
} |
|
13 |
public void setId(String id) { |
|
14 |
this.id = id; |
|
15 |
} |
|
16 |
public String getName() { |
|
17 |
return name; |
|
18 |
} |
|
19 |
public void setName(String name) { |
|
20 |
this.name = name; |
|
21 |
} |
|
22 |
public boolean isChosen() { |
|
23 |
return chosen; |
|
24 |
} |
|
25 |
public void setChosen(boolean chosen) { |
|
26 |
this.chosen = chosen; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/FieldPair.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
public class FieldPair { |
|
4 |
|
|
5 |
private String fieldName, fieldValue; |
|
6 |
|
|
7 |
public String getFieldName() { |
|
8 |
return fieldName; |
|
9 |
} |
|
10 |
|
|
11 |
public void setFieldName(String fieldName) { |
|
12 |
this.fieldName = fieldName; |
|
13 |
} |
|
14 |
|
|
15 |
public String getFieldValue() { |
|
16 |
return fieldValue; |
|
17 |
} |
|
18 |
|
|
19 |
public void setFieldValue(String fieldValue) { |
|
20 |
this.fieldValue = fieldValue; |
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
} |
modules/uoa-madgik-validator/branches/uoa-madgik-validator-1.0.2/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/PrepareAddRule.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validator.constants.RuleTypes; |
|
5 |
import gr.uoa.di.validator.dao.RulePair; |
|
6 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
7 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
8 |
|
|
9 |
import java.util.List; |
|
10 |
import java.util.Set; |
|
11 |
|
|
12 |
import org.apache.log4j.Logger; |
|
13 |
|
|
14 |
import com.opensymphony.xwork2.Action; |
|
15 |
|
|
16 |
public class PrepareAddRule extends BaseValidatorAction { |
|
17 |
|
|
18 |
private static final long serialVersionUID = -8414397033694574297L; |
|
19 |
private Logger logger = Logger.getLogger(PrepareAddRule.class); |
|
20 |
|
|
21 |
private String type; |
|
22 |
private List<String> labels; |
|
23 |
private String[] jobTypes; |
Also available in: Unified diff
creating a 1.0.2 branch to fix a bug in release 1.0.1