Project

General

Profile

« Previous | Next » 

Revision 41280

Added by Nikon Gasparis almost 9 years ago

added method to get Rulesets
fixed a bug while loading Guidelines

View differences:

modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/RepositoryServiceImpl.java
292 292
                        retMap.put(entry.getKey(), entry.getValue());
293 293
                }
294 294
            }
295
            if (!foundData)
295

  
296
            //TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED
297
            if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA) && !foundData)
296 298
                retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)");
297 299

  
298 300
            return retMap;
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/ValidationServiceImpl.java
2 2

  
3 3
import eu.dnetlib.api.functionality.ValidatorService;
4 4
import eu.dnetlib.domain.functionality.validator.JobForValidation;
5
import eu.dnetlib.domain.functionality.validator.RuleSet;
5 6
import eu.dnetlib.repo.manager.client.services.ValidationService;
6 7
import eu.dnetlib.repo.manager.server.utils.EmailUtils;
7 8
import eu.dnetlib.repo.manager.server.utils.OaiTools;
9
import eu.dnetlib.repo.manager.shared.Constants;
8 10
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
9 11
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
10 12
import gr.uoa.di.driver.util.ServiceLocator;
11 13
import org.apache.log4j.Logger;
12 14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.beans.factory.annotation.Value;
13 16
import org.springframework.stereotype.Service;
14 17

  
18
import javax.annotation.PostConstruct;
15 19
import javax.servlet.ServletConfig;
16 20
import javax.servlet.ServletException;
21
import java.util.ArrayList;
17 22
import java.util.List;
23
import java.util.Map;
24
import java.util.concurrent.ConcurrentHashMap;
18 25

  
19 26
/**
20 27
 * Created by nikonas on 22/12/15.
......
28 35
    @Autowired
29 36
    private EmailUtils emailUtils;
30 37

  
38
    @Value("${services.repo-manager.deploy.environment}")
39
    private String deployEnvironment;
40

  
31 41
    private ServiceLocator<ValidatorService> validatorServiceLocator;
32 42

  
43
    private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
44

  
33 45
    public void init(ServletConfig config) throws ServletException {
34 46

  
35 47
        LOGGER.info("initializing validation service impl ");
36 48
        super.init(config);
49
    }
37 50

  
51
    @PostConstruct
52
    public void initRulesets() {
53
        this.loadRulesets();
38 54
    }
39 55

  
40 56
    @Override
......
80 96
    }
81 97

  
82 98
    @Override
99
    public List<RuleSet> getRuleSets(String validationMode) throws ValidationServiceException {
100
        LOGGER.info("Getting rulesets for mode: " + validationMode);
101
        try {
102
            if (!rulesetMap.containsKey(validationMode))
103
                this.loadRulesets();
104

  
105
            return this.rulesetMap.get(validationMode);
106
        } catch (Exception e) {
107
            LOGGER.error("Error getting rulesets", e);
108
            emailUtils.reportException(e);
109
            throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
110
        }
111
    }
112

  
113
    @Override
83 114
    public void submitValidationJob(JobForValidation job) throws ValidationServiceException {
84 115
        try {
85 116
            LOGGER.info("Submitting validation job");
......
90 121
        }
91 122
    }
92 123

  
124
    private void loadRulesets() {
125
        try {
126
            LOGGER.debug("loading rulesets");
127
            for (RuleSet ruleSet : getValidationService().getRuleSets()) {
128
                if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains(deployEnvironment)) {
129
                    String key = "";
130
                    if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
131
                        key = Constants.VALIDATION_MODE_DATA;
132
                    else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
133
                        key = Constants.VALIDATION_MODE_LITERATURE;
134
                    else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
135
                        key = Constants.VALIDATION_MODE_CRIS;
136

  
137
                    if (rulesetMap.containsKey(key))
138
                        rulesetMap.get(key).add(ruleSet);
139
                    else {
140
                        List<RuleSet> ruleSets = new ArrayList<RuleSet>();
141
                        ruleSets.add(ruleSet);
142
                        rulesetMap.put(key, ruleSets);
143
                    }
144
                }
145
            }
146
        } catch (Exception e) {
147
            LOGGER.error("Error getting rulesets", e);
148
            emailUtils.reportException(e);
149
        }
150
    }
151

  
93 152
    private ValidatorService getValidationService() {
94 153
        return this.validatorServiceLocator.getService();
95 154
    }
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/services/ValidationService.java
3 3
import com.google.gwt.user.client.rpc.RemoteService;
4 4
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
5 5
import eu.dnetlib.domain.functionality.validator.JobForValidation;
6
import eu.dnetlib.domain.functionality.validator.RuleSet;
6 7
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
7 8
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
8 9

  
......
20 21

  
21 22
    InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
22 23

  
24
    List<RuleSet> getRuleSets(String validationMode) throws ValidationServiceException;
25

  
23 26
    void submitValidationJob(JobForValidation job) throws ValidationServiceException;
24 27
}
modules/uoa-repository-manager-gui/trunk/src/main/resources/eu/dnetlib/repo/manager/server/springContext-repo-manager.properties
13 13
# if set to true, getRepositories will return dummy repositories
14 14
services.repo-manager.repository.testing.mode = false
15 15

  
16
services.repo-manager.deploy.environment = development
17

  
16 18
# the mailhost for the mail service
17 19
services.validator.mail.host = smtp.gmail.com
18 20
# the port where the mail service is running

Also available in: Unified diff