Project

General

Profile

« Previous | Next » 

Revision 57006

Cleaning up and adding the OR clause (job.isRegistration || job.isUpdate)

View differences:

ValidatorManagerImpl.java
218 218
		try {
219 219
			logger.info("Submiting validation job requested by user: " + job.getUserEmail());
220 220

  
221
			if (job.isRegistration()) {
221

  
222
			if (job.isRegistration() || job.isUpdateExisting()) {
222 223
				logger.debug("initiating preregistration validations on repo " + job.getBaseUrl() + " for user " + job.getUserEmail() + "and desired compatibility: " + job.getDesiredCompatibilityLevel());
223
				for (RuleSet ruleset : rulesetsDao.getRuleSets()) {
224
					if (ruleset.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) {
225
						job.setSelectedContentRules(ruleset.getContentRulesIds());
226
						job.setSelectedUsageRules(ruleset.getUsageRulesIds());
227
					}	
228
				}	
224

  
225
				for (RuleSet ruleset : rulesetsDao.getRuleSets(job.getDesiredCompatibilityLevel())) {
226
					job.setSelectedContentRules(ruleset.getContentRulesIds());
227
					job.setSelectedUsageRules(ruleset.getUsageRulesIds());
228
				}
229 229
			}
230 230
			
231 231
			if ( job.getDesiredCompatibilityLevel().toLowerCase().matches("^openaire4.0$") ) {
......
251 251
				logger.debug("Chosen set: OpenAIRE For Cris");
252 252
				logger.debug("Setting METADATA_PREFIX to: oai_CERIF_openaire");
253 253
				job.setMetadataPrefix("oai_CERIF_openaire");			
254
			} else {
255
				logger.error("Cannot set metadata prefx for " + job.getDesiredCompatibilityLevel() + " guidelines");
254 256
			}
255 257
			
256 258
			
......
264 266
			
265 267
			if (job.getSelectedContentRules() != null) {
266 268
				contentJobs = 1;
267
				validationType +="C";
269
				validationType += "C";
268 270
				totalRules.addAll(job.getSelectedContentRules());
269 271
				newJob.setContentJobStatus("ongoing");
270 272
			} else {
271 273
				newJob.setContentJobStatus("none");
272 274
			}
275

  
273 276
			if (job.getSelectedUsageRules() != null) {
274 277
				logger.debug("Creating map for provider information");
275 278
				verbRuleMap= new HashMap<String,Set<Integer>>();
276 279
				Set<Integer> old,temp = null;
280

  
277 281
				for (Integer id : job.getSelectedUsageRules()){
278 282
					eu.dnetlib.domain.functionality.validator.Rule ruleStored = rulesDao.get(id);
279 283
					logger.debug("Checking for verb : "+ruleStored.getProvider_information());
......
310 314
				newJob.setSelectedCrisEntities(job.getSelectedCrisEntities());
311 315
				newJob.setCrisReferentialChecks(job.isCrisReferentialChecks());
312 316
			}
317

  
313 318
			newJob.setValidationType(validationType);
314
			if (job.isRegistration()) {
319

  
320
			if (job.isRegistration() || job.isUpdateExisting()) {
315 321
				newJob.setJobType("Registration Request");
316 322
				//TODO move in uoa-domain
317 323
				newJob.setActivationId(job.getActivationId());
......
332 338
	
333 339
			int jobIdStored = jobsDao.save(newJob);
334 340
			
335

  
336 341
			RegistrationListener regListener = null;
337
			if (job.isRegistration()) {
342
			if (job.isRegistration() || job.isUpdateExisting()) {
338 343
				regListener = listenersManager.createRegListener();
339
//				regListener.setActivationId(job.getActivationId());
340
//				regListener.setBaseUrl(job.getBaseUrl());
341
//				regListener.setActivationId(job.getActivationId());
342
//				regListener.setAdminEmails(job.getAdminEmails());
343
//				regListener.setOfficialName(job.getOfficialName());
344 344
				regListener.setUserMail(job.getUserEmail());
345 345
				regListener.setDatasourceId(job.getDatasourceId());
346 346
				regListener.setInterfaceId(job.getInterfaceId());
347
//				regListener.setValidationSet(job.getValidationSet());
348
//				regListener.setDesiredCompLevel(job.getDesiredCompatibilityLevel());
349
//				regListener.setRepoType(job.getRepoType());
350
//				regListener.setInterfaceIdOld(job.getInterfaceIdOld());
351
				regListener.setUpdateExisting(job.isUpdateExisting());	
347
				regListener.setUpdateExisting(job.isUpdateExisting());
352 348
				regListener.setTotalJobs(usageJobs + contentJobs);
353 349
			}
354 350
			
......
356 352
			compTestListener.setValidationSet(job.getValidationSet());
357 353
			compTestListener.setGuidelines(job.getDesiredCompatibilityLevel());
358 354
			compTestListener.setTotalJobs(usageJobs + contentJobs);
359

  
360 355
			
361
//CONTENT
356
			//CONTENT
362 357
			if (job.getSelectedContentRules() != null) {
363
			
364 358
				Set<Rule> rulesContent = new HashSet<Rule>();
365
				
366 359
				Properties props = new Properties();
360

  
367 361
				props.setProperty(OAIPMHRecordProvider.BASEURL, job.getBaseUrl());
368 362
				props.setProperty(OAIPMHRecordProvider.METADATA_PREFIX, newJob.getMetadataPrefix());
369 363
				props.setProperty(OAIPMHRecordProvider.RECORDS,Integer.toString(job.getRecords()));
370 364
				props.setProperty(OAIPMHRecordProvider.SET,job.getValidationSet());
371 365
				
372
		
373 366
				Job jobContent = null;
374 367
				
375 368
				ValidatorJobListener listenerContent = listenersManager.createListener();
369

  
376 370
				listenerContent.setJobSubmittedId(jobIdStored);
377 371
				listenerContent.setJobSubmittedUser(job.getUserEmail());
378 372
				listenerContent.setGroupBy_xpath(newJob.getGroupByXpath());
379 373
				listenerContent.setValidationType("content");
380 374
				listenerContent.setInternalJobsSum(contentJobs);
381
				
382 375

  
383 376
				if (job.isCris()) {
384 377
					logger.debug("Submiting job for cris.");
385 378
					logger.debug("Total content jobs: " + contentJobs);
386
//					logger.debug("Selected content rules number: " + job.getSelectedContentRules().size());
387 379
					jobContent = new Job(jobIdStored, 4, rulesContent, props);
388
// acz					validator.submitJobForCris(jobContent, entityChosenRulesMap, entityChosenRulesMapReferential, listenerContent, compTestListener);
389
// send cris validation to Guideline team member. Could be moved into MemoryThreadValidator.submitJobForCris method
390
                                        List<String> recipientsMailAddr = new ArrayList<String>();
391
                                        recipientsMailAddr.add("andreas.czerniak@uni-bielefeld.de");
392
                                        emailer.sendMail( recipientsMailAddr, "CrisJob submitting", "baseUrl: " + job.getBaseUrl() , false, recipientsMailAddr);
393
                                } else {
394
					
380
					// acz
381
					// validator.submitJobForCris(jobContent, entityChosenRulesMap, entityChosenRulesMapReferential, listenerContent, compTestListener);
382
					// send cris validation to Guideline team member. Could be moved into MemoryThreadValidator.submitJobForCris method
383
					List<String> recipientsMailAddr = new ArrayList<String>();
384
					recipientsMailAddr.add("andreas.czerniak@uni-bielefeld.de");
385
					emailer.sendMail( recipientsMailAddr, "CrisJob submitting", "baseUrl: " + job.getBaseUrl() , false, recipientsMailAddr);
386
				} else {
395 387
					logger.debug("Selected content rules number: " + job.getSelectedContentRules().size());
396 388
					for (Integer ruleId : job.getSelectedContentRules()){
389
						eu.dnetlib.domain.functionality.validator.Rule tempRule= rulesDao.get(ruleId);
397 390
						
398
						eu.dnetlib.domain.functionality.validator.Rule tempRule=rulesDao.get(ruleId);
399
						
400 391
						//special behaviour type of rule is chain
401
						if(tempRule.getType().equals("ChainRule")) {
392
						if (tempRule.getType().equals("ChainRule")) {
402 393
							ChainRule<Rule> chainRule = this.handleChain(tempRule);
403 394
							rulesContent.add(chainRule);
404
						}
405
						else {
395
						} else
406 396
							rulesContent.add((Rule) this.getRuleClassInstanceByType(tempRule.getType(), tempRule.getConfiguration(), tempRule.getId()));
407
						}
408 397
					}
409 398
					
410 399
					jobContent = new Job(jobIdStored, 1, rulesContent, props);
411 400
					
412
					if (job.isRegistration()) {
401
					if (job.isRegistration() || job.isUpdateExisting()) {
413 402
						validator.submitJob(jobContent, 1, listenerContent, regListener);
414 403
					} else {
415 404
						validator.submitJob(jobContent, 1, listenerContent, compTestListener);
......
439 428
					jobsUsage.add(new Job(jobIdStored, 2, rulesUsage, pros));
440 429
				}
441 430
				for (Job jobUsage : jobsUsage ) {
442
					if (job.isRegistration()) {
431
					if (job.isRegistration() || job.isUpdateExisting()) {
443 432
						validator.submitJob(jobUsage, 1, listenerUsage, regListener);
444 433
					} else {
445 434
						validator.submitJob(jobUsage, 1, listenerUsage, compTestListener);

Also available in: Unified diff