Revision 45617
Added by Michele Artini over 7 years ago
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/CommonController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import com.google.gson.Gson; |
|
7 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
8 |
import eu.dnetlib.rmi.enabling.ISLookUpService; |
|
9 |
import eu.dnetlib.rmi.enabling.ISRegistryService; |
|
10 |
import org.apache.commons.io.IOUtils; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.stereotype.Controller; |
|
13 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
14 |
import org.springframework.web.bind.annotation.RequestParam; |
|
15 |
|
|
16 |
@Controller |
|
17 |
public class CommonController { |
|
18 |
|
|
19 |
@Autowired |
|
20 |
private UniqueServiceLocator serviceLocator; |
|
21 |
|
|
22 |
@RequestMapping(value = "/ui/**/getProfile") |
|
23 |
public void getProfile(final HttpServletResponse res, |
|
24 |
@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
25 |
res.setContentType("text/xml"); |
|
26 |
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(id); |
|
27 |
IOUtils.copy(new StringReader(profile), res.getOutputStream()); |
|
28 |
} |
|
29 |
|
|
30 |
@RequestMapping(value = "/ui/**/getSchema") |
|
31 |
public void getSchema(final HttpServletResponse res, |
|
32 |
@RequestParam(value = "name", required = true) final String name) throws Exception { |
|
33 |
res.setContentType("text/xml"); |
|
34 |
final String schema = this.serviceLocator.getService(ISLookUpService.class).getResourceTypeSchema(name); |
|
35 |
IOUtils.copy(new StringReader(schema), res.getOutputStream()); |
|
36 |
} |
|
37 |
|
|
38 |
@RequestMapping(value = "/ui/**/validateProfile") |
|
39 |
public void validate(final HttpServletResponse res, |
|
40 |
@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
41 |
final String newId = this.serviceLocator.getService(ISRegistryService.class).validateProfile(id); |
|
42 |
IOUtils.copy(new StringReader(new Gson().toJson(newId)), res.getOutputStream()); |
|
43 |
} |
|
44 |
|
|
45 |
@RequestMapping(value = "/ui/**/deleteProfile") |
|
46 |
public void deleteProfile(final HttpServletResponse res, |
|
47 |
@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
48 |
final boolean b = this.serviceLocator.getService(ISRegistryService.class).deleteProfile(id); |
|
49 |
IOUtils.copy(new StringReader(new Gson().toJson(b)), res.getOutputStream()); |
|
50 |
} |
|
51 |
|
|
52 |
} |
modules/dnet-springboot-apps/trunk/pom.xml | ||
---|---|---|
32 | 32 |
<module>dnet-common-utils</module> |
33 | 33 |
<module>dnet-is-application</module> |
34 | 34 |
<module>dnet-simple-aggregation-worker</module> |
35 |
<module>dnet-administration-uis</module> |
|
35 | 36 |
</modules> |
36 | 37 |
|
37 | 38 |
<dependencies> |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/RegistryServiceVocabularyDAO.java | ||
---|---|---|
32 | 32 |
"for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') order by $x//VOCABULARY_NAME " |
33 | 33 |
+ "return concat ($x//RESOURCE_IDENTIFIER/@value,' §§§ ',$x//VOCABULARY_NAME,' §§§ ',$x//VOCABULARY_DESCRIPTION,' §§§ ',$x//VOCABULARY_NAME/@code)"; |
34 | 34 |
|
35 |
final List<Vocabulary> vocabularies = Lists.transform(this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query),
|
|
35 |
final List<Vocabulary> vocabularies = Lists.transform(this.isClient.find(query),
|
|
36 | 36 |
s -> { |
37 | 37 |
final String[] tokens = s.split("§§§"); |
38 | 38 |
return new Vocabulary(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim()); |
... | ... | |
46 | 46 |
@Override |
47 | 47 |
public List<Term> getTerms(final String vocabularyId) throws VocabularyException { |
48 | 48 |
try { |
49 |
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(vocabularyId);
|
|
49 |
final String profile = this.isClient.getProfile(vocabularyId);
|
|
50 | 50 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
51 | 51 |
final Map<String, Term> terms = Maps.newHashMap(); |
52 | 52 |
|
... | ... | |
150 | 150 |
st.setAttribute("description", voc.getDescription()); |
151 | 151 |
st.setAttribute("code", voc.getCode()); |
152 | 152 |
st.setAttribute("date", DateUtils.now_ISO8601()); |
153 |
final String newVocabularyId = this.serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString());
|
|
153 |
final String newVocabularyId = this.isClient.register(st.toString());
|
|
154 | 154 |
|
155 | 155 |
return newVocabularyId; |
156 | 156 |
} catch (final IOException e) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/RepoApisEntryPointController.java | ||
---|---|---|
15 | 15 |
public class RepoApisEntryPointController extends ModuleEntryPoint { |
16 | 16 |
|
17 | 17 |
@Autowired |
18 |
private UniqueServiceLocator serviceLocator;
|
|
18 |
private InformationServiceClient isClient;
|
|
19 | 19 |
|
20 | 20 |
@Autowired |
21 | 21 |
private RepoUIUtils repoUIUtils; |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/RepoInternalController.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
private static final Log log = LogFactory.getLog(RepoInternalController.class); |
33 | 33 |
@Autowired |
34 |
private UniqueServiceLocator serviceLocator;
|
|
34 |
private InformationServiceClient isClient;
|
|
35 | 35 |
@Autowired |
36 | 36 |
private WorkflowSectionGrouper workflowSectionGrouper; |
37 | 37 |
@Autowired |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/AddRepoApiEntryPointController.java | ||
---|---|---|
30 | 30 |
private String protocolsVocabulary; |
31 | 31 |
|
32 | 32 |
@Autowired |
33 |
private UniqueServiceLocator serviceLocator;
|
|
33 |
private InformationServiceClient isClient;
|
|
34 | 34 |
|
35 | 35 |
@Autowired |
36 | 36 |
private RepoUIUtils repoUIUtils; |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/AddRepoEntryPointController.java | ||
---|---|---|
20 | 20 |
private String datasourceCountryVocabulary; |
21 | 21 |
|
22 | 22 |
@Autowired |
23 |
private UniqueServiceLocator serviceLocator;
|
|
23 |
private InformationServiceClient isClient;
|
|
24 | 24 |
|
25 | 25 |
@Autowired |
26 | 26 |
private RepoUIUtils repoUIUtils; |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/util/RepoUIUtils.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
private final Map<String, List<ProtocolParameter>> parametersMap = new HashMap<>(); |
21 | 21 |
@Autowired |
22 |
private UniqueServiceLocator serviceLocator;
|
|
22 |
private InformationServiceClient isClient;
|
|
23 | 23 |
|
24 | 24 |
public List<VocabularyEntry> fetchVocabularyTerms(final String voc) throws ISLookUpException { |
25 | 25 |
final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '" |
26 | 26 |
+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)"; |
27 | 27 |
|
28 | 28 |
final List<VocabularyEntry> list = Lists.newArrayList(); |
29 |
for (final String s : this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
|
|
29 |
for (final String s : this.isClient.find(xquery)) {
|
|
30 | 30 |
final String[] arr = s.split("@@@"); |
31 | 31 |
list.add(new VocabularyEntry(arr[0].trim(), arr[1].trim())); |
32 | 32 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListProfilesValues.java | ||
---|---|---|
12 | 12 |
public class ListProfilesValues extends ValidNodeValuesFetcher { |
13 | 13 |
|
14 | 14 |
@Autowired |
15 |
private UniqueServiceLocator serviceLocator;
|
|
15 |
private InformationServiceClient isClient;
|
|
16 | 16 |
|
17 | 17 |
@Override |
18 | 18 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
... | ... | |
23 | 23 |
final String query = "for $x in /*[.//RESOURCE_TYPE/@value='" + params.get("type") + "']" + "return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x" |
24 | 24 |
+ params.get("xpath") + ")"; |
25 | 25 |
|
26 |
final List<String> result = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
|
|
26 |
final List<String> result = this.isClient.find(query);
|
|
27 | 27 |
for (final String s : result) { |
28 | 28 |
final String[] arr = s.split("@@@"); |
29 | 29 |
values.add(new DnetParamValue(arr[0].trim(), arr[1].trim())); |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListProtocolFieldValues.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.List; |
5 | 5 |
import java.util.Map; |
6 |
import java.util.concurrent.*; |
|
6 |
import java.util.concurrent.ExecutorService; |
|
7 |
import java.util.concurrent.Executors; |
|
8 |
import java.util.concurrent.Future; |
|
9 |
import java.util.concurrent.TimeUnit; |
|
7 | 10 |
|
8 |
import com.google.common.base.Function; |
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
11 |
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher; |
|
12 |
import eu.dnetlib.rmi.data.CollectorService; |
|
13 |
import eu.dnetlib.rmi.data.ProtocolParameterValue; |
|
14 | 11 |
import org.apache.commons.logging.Log; |
15 | 12 |
import org.apache.commons.logging.LogFactory; |
16 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 14 |
|
15 |
import com.google.common.collect.Lists; |
|
16 |
|
|
17 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
18 |
|
|
18 | 19 |
public class ListProtocolFieldValues extends ValidNodeValuesFetcher { |
19 | 20 |
|
20 | 21 |
private static final Log log = LogFactory.getLog(ListProtocolFieldValues.class); |
21 | 22 |
private final ExecutorService pool = Executors.newFixedThreadPool(10); |
22 | 23 |
@Autowired |
23 |
private UniqueServiceLocator serviceLocator;
|
|
24 |
private InformationServiceClient isClient;
|
|
24 | 25 |
|
25 | 26 |
@Override |
26 | 27 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
... | ... | |
30 | 31 |
final String baseUrl = params.get("baseUrl"); |
31 | 32 |
final String field = params.get("field"); |
32 | 33 |
|
33 |
final Future<List<DnetParamValue>> futureList = this.pool.submit(new Callable<List<DnetParamValue>>() { |
|
34 |
final Future<List<DnetParamValue>> futureList = pool.submit(() -> { |
|
35 |
final List<ProtocolParameterValue> list = |
|
36 |
getServiceLocator().getService(CollectorService.class).listValidValuesForParam(protocol, baseUrl, field, null); |
|
34 | 37 |
|
35 |
@Override |
|
36 |
public List<DnetParamValue> call() throws Exception { |
|
37 |
final List<ProtocolParameterValue> list = |
|
38 |
getServiceLocator().getService(CollectorService.class).listValidValuesForParam(protocol, baseUrl, field, null); |
|
39 |
|
|
40 |
return Lists.newArrayList(Lists.transform(list, new Function<ProtocolParameterValue, ValidNodeValuesFetcher.DnetParamValue>() { |
|
41 |
|
|
42 |
@Override |
|
43 |
public DnetParamValue apply(final ProtocolParameterValue ppv) { |
|
44 |
return new DnetParamValue(ppv.getId(), ppv.getName()); |
|
45 |
} |
|
46 |
})); |
|
47 |
} |
|
38 |
return Lists.newArrayList(Lists.transform(list, ppv -> new DnetParamValue(ppv.getId(), ppv.getName()))); |
|
48 | 39 |
}); |
49 | 40 |
|
50 | 41 |
try { |
... | ... | |
57 | 48 |
} |
58 | 49 |
|
59 | 50 |
public UniqueServiceLocator getServiceLocator() { |
60 |
return this.serviceLocator;
|
|
51 |
return serviceLocator; |
|
61 | 52 |
} |
62 | 53 |
|
63 | 54 |
public void setServiceLocator(final UniqueServiceLocator serviceLocator) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListDedupOrchestrationValues.java | ||
---|---|---|
12 | 12 |
public class ListDedupOrchestrationValues extends ValidNodeValuesFetcher { |
13 | 13 |
|
14 | 14 |
@Resource |
15 |
private UniqueServiceLocator serviceLocator;
|
|
15 |
private InformationServiceClient isClient;
|
|
16 | 16 |
|
17 | 17 |
@Override |
18 | 18 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
... | ... | |
20 | 20 |
final String xquery = |
21 | 21 |
"for $x in /RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='DedupOrchestrationDSResourceType'] return $x//ACTION_SET/@id/string()"; |
22 | 22 |
|
23 |
final List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
23 |
final List<String> result = isClient.find(xquery);
|
|
24 | 24 |
final List<DnetParamValue> values = Lists.newArrayList(); |
25 | 25 |
|
26 | 26 |
for (final String s : result) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListDownloadPluginValues.java | ||
---|---|---|
17 | 17 |
/** The download plugin enumerator. */ |
18 | 18 |
|
19 | 19 |
@Autowired |
20 |
private UniqueServiceLocator serviceLocator;
|
|
20 |
private InformationServiceClient isClient;
|
|
21 | 21 |
|
22 | 22 |
@Override |
23 | 23 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListActionManagerSetsValues.java | ||
---|---|---|
12 | 12 |
public class ListActionManagerSetsValues extends ValidNodeValuesFetcher { |
13 | 13 |
|
14 | 14 |
@Resource |
15 |
private UniqueServiceLocator serviceLocator;
|
|
15 |
private InformationServiceClient isClient;
|
|
16 | 16 |
|
17 | 17 |
@Override |
18 | 18 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
... | ... | |
20 | 20 |
final String xquery = |
21 | 21 |
"for $x in /RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='ActionManagerSetDSResourceType'] return concat($x//SET/@id, ' @@@ ', $x//SET) "; |
22 | 22 |
|
23 |
final List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
23 |
final List<String> result = isClient.find(xquery);
|
|
24 | 24 |
final List<DnetParamValue> values = Lists.newArrayList(new DnetParamValue("", "ALL SETS")); |
25 | 25 |
|
26 | 26 |
for (final String s : result) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListDedupConfigValues.java | ||
---|---|---|
12 | 12 |
public class ListDedupConfigValues extends ValidNodeValuesFetcher { |
13 | 13 |
|
14 | 14 |
@Resource |
15 |
private UniqueServiceLocator serviceLocator;
|
|
15 |
private InformationServiceClient isClient;
|
|
16 | 16 |
|
17 | 17 |
@Override |
18 | 18 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
... | ... | |
20 | 20 |
final String xquery = |
21 | 21 |
"for $x in /RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='DedupConfigurationDSResourceType'] return concat($x//CONFIGURATION/@id, ' @@@ ', $x//DESCRIPTION) "; |
22 | 22 |
|
23 |
final List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
23 |
final List<String> result = isClient.find(xquery);
|
|
24 | 24 |
final List<DnetParamValue> values = Lists.newArrayList(); |
25 | 25 |
|
26 | 26 |
for (final String s : result) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListHBaseTables.java | ||
---|---|---|
30 | 30 |
}; |
31 | 31 |
|
32 | 32 |
@Resource |
33 |
private UniqueServiceLocator serviceLocator;
|
|
33 |
private InformationServiceClient isClient;
|
|
34 | 34 |
|
35 | 35 |
@Override |
36 | 36 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListHadoopClusters.java | ||
---|---|---|
29 | 29 |
}; |
30 | 30 |
|
31 | 31 |
@Resource |
32 |
private UniqueServiceLocator serviceLocator;
|
|
32 |
private InformationServiceClient isClient;
|
|
33 | 33 |
|
34 | 34 |
@Override |
35 | 35 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListHBaseMappingTitleValues.java | ||
---|---|---|
13 | 13 |
public class ListHBaseMappingTitleValues extends ValidNodeValuesFetcher { |
14 | 14 |
|
15 | 15 |
@Resource |
16 |
private UniqueServiceLocator serviceLocator;
|
|
16 |
private InformationServiceClient isClient;
|
|
17 | 17 |
|
18 | 18 |
private String sourceFormat; |
19 | 19 |
|
... | ... | |
28 | 28 |
+ ".//SOURCE_METADATA_FORMAT/@interpretation = 'cleaned'] " |
29 | 29 |
+ "return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//SCRIPT/TITLE/text())"; |
30 | 30 |
|
31 |
final List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
31 |
final List<String> result = isClient.find(xquery);
|
|
32 | 32 |
final List<DnetParamValue> values = Lists.newArrayList(); |
33 | 33 |
|
34 | 34 |
for (final String s : result) { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WorkflowsController.java | ||
---|---|---|
116 | 116 |
private DnetLogger dnetLogger; |
117 | 117 |
|
118 | 118 |
@Autowired |
119 |
private UniqueServiceLocator serviceLocator;
|
|
119 |
private InformationServiceClient isClient;
|
|
120 | 120 |
|
121 | 121 |
@Value("${repo.ui.compatibilityLevels.vocabulary}") |
122 | 122 |
private String compatibilityLevelsVocabulary; |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/util/ISRegistryClient.java | ||
---|---|---|
3 | 3 |
import java.io.StringReader; |
4 | 4 |
import java.util.Map; |
5 | 5 |
|
6 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
7 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowNotificationInfo; |
|
8 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowUpdateInfo; |
|
9 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
10 |
import eu.dnetlib.rmi.enabling.ISRegistryException; |
|
11 |
import eu.dnetlib.rmi.enabling.ISRegistryService; |
|
12 | 6 |
import org.apache.commons.logging.Log; |
13 | 7 |
import org.apache.commons.logging.LogFactory; |
14 | 8 |
import org.dom4j.Document; |
... | ... | |
17 | 11 |
import org.dom4j.io.SAXReader; |
18 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
19 | 13 |
|
14 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
15 |
import eu.dnetlib.exceptions.InformationServiceException; |
|
16 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowNotificationInfo; |
|
17 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowUpdateInfo; |
|
18 |
|
|
20 | 19 |
public class ISRegistryClient { |
21 | 20 |
|
22 | 21 |
private static final Log log = LogFactory.getLog(ISRegistryClient.class); |
23 | 22 |
@Autowired |
24 |
private UniqueServiceLocator serviceLocator;
|
|
23 |
private InformationServiceClient isClient;
|
|
25 | 24 |
|
26 |
public String registerProfile(final String profile) throws ISRegistryException {
|
|
27 |
return this.serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
|
|
25 |
public String registerProfile(final String profile) throws InformationServiceException {
|
|
26 |
return isClient.register(profile);
|
|
28 | 27 |
} |
29 | 28 |
|
30 |
public void deleteProfile(final String id) throws ISRegistryException {
|
|
31 |
this.serviceLocator.getService(ISRegistryService.class).deleteProfile(id);
|
|
29 |
public void deleteProfile(final String id) throws InformationServiceException {
|
|
30 |
isClient.deleteProfile(id);
|
|
32 | 31 |
} |
33 | 32 |
|
34 | 33 |
public boolean updateWorkflowProfile(final String wfId, final String profile, final Map<String, String> map) throws Exception { |
... | ... | |
55 | 54 |
((Element) doc.selectSingleNode("//CONFIGURATION")).addAttribute("status", WorkflowStatus.WAIT_USER_SETTINGS.name()); |
56 | 55 |
} |
57 | 56 |
|
58 |
return this.serviceLocator.getService(ISRegistryService.class).updateProfile(wfId, doc.asXML(), doc.valueOf("//RESOURCE_TYPE/@value")); |
|
57 |
isClient.updateProfile(wfId, doc.asXML()); |
|
58 |
|
|
59 |
return true; |
|
59 | 60 |
} |
60 | 61 |
|
61 | 62 |
public boolean updateWorkflowProfile(final String wfId, final String profile, final WorkflowUpdateInfo info) throws Exception { |
... | ... | |
82 | 83 |
node.selectSingleNode("./CRON").setText(info.getCron() != null ? info.getCron() : ""); |
83 | 84 |
node.selectSingleNode("./MININTERVAL").setText(Integer.toString(info.getInterval())); |
84 | 85 |
} |
85 |
return this.serviceLocator.getService(ISRegistryService.class).updateProfile(wfId, doc.asXML(), doc.valueOf("//RESOURCE_TYPE/@value")); |
|
86 |
isClient.updateProfile(wfId, doc.asXML()); |
|
87 |
|
|
88 |
return true; |
|
86 | 89 |
} |
87 | 90 |
|
88 | 91 |
public void updateWorkflowStatus(final String id, final WorkflowStatus status) throws ISRegistryException { |
89 |
this.serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//CONFIGURATION/@status", "'" + status.toString() + "'");
|
|
92 |
isClient.updateProfileNode(id, "//CONFIGURATION/@status", "'" + status.toString() + "'");
|
|
90 | 93 |
} |
91 | 94 |
|
92 | 95 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/util/ISLookupClient.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.functionality.modular.ui.workflows.util; |
2 | 2 |
|
3 | 3 |
import java.io.StringReader; |
4 |
import java.util.*; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Collections; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
import java.util.Set; |
|
5 | 10 |
import java.util.stream.Collectors; |
6 | 11 |
|
7 |
import com.google.common.base.Function; |
|
8 |
import com.google.common.base.Splitter; |
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import com.google.common.collect.Sets; |
|
11 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
12 |
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoHIWorkflow; |
|
13 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowItem; |
|
14 |
import eu.dnetlib.miscutils.collections.Pair; |
|
15 |
import eu.dnetlib.rmi.enabling.ISLookUpDocumentNotFoundException; |
|
16 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
|
17 |
import eu.dnetlib.rmi.enabling.ISLookUpService; |
|
18 | 12 |
import org.antlr.stringtemplate.StringTemplate; |
19 | 13 |
import org.apache.commons.io.IOUtils; |
20 | 14 |
import org.apache.commons.lang3.StringUtils; |
... | ... | |
27 | 21 |
import org.springframework.beans.factory.annotation.Autowired; |
28 | 22 |
import org.springframework.core.io.ClassPathResource; |
29 | 23 |
|
24 |
import com.google.common.base.Splitter; |
|
25 |
import com.google.common.collect.Lists; |
|
26 |
import com.google.common.collect.Sets; |
|
27 |
|
|
28 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
29 |
import eu.dnetlib.exceptions.InformationServiceException; |
|
30 |
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoHIWorkflow; |
|
31 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowItem; |
|
32 |
import eu.dnetlib.miscutils.collections.Pair; |
|
33 |
|
|
30 | 34 |
public class ISLookupClient { |
31 | 35 |
|
32 | 36 |
private static final Log log = LogFactory.getLog(ISLookupClient.class); |
33 | 37 |
|
34 | 38 |
@Autowired |
35 |
private UniqueServiceLocator serviceLocator;
|
|
39 |
private InformationServiceClient isClient;
|
|
36 | 40 |
|
37 | 41 |
public List<String> listSimpleWorflowSections() { |
38 | 42 |
final String xquery = "distinct-values(//WORKFLOW_NAME/@menuSection/string())"; |
39 | 43 |
try { |
40 |
return this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
41 |
} catch (final ISLookUpException e) {
|
|
44 |
return isClient.find(xquery);
|
|
45 |
} catch (final InformationServiceException e) {
|
|
42 | 46 |
log.error("Error obtaining worflowSections", e); |
43 | 47 |
return Lists.newArrayList(); |
44 | 48 |
} |
... | ... | |
62 | 66 |
+ " order by $x//WORKFLOW_NAME return concat($x//RESOURCE_IDENTIFIER/@value, ' ==@== ', $x//WORKFLOW_NAME, ' ==@== ', $x//WORKFLOW_DESCRIPTION, ' ==@== ', $x//DESTROY_WORKFLOW_TEMPLATE/@id)"; |
63 | 67 |
|
64 | 68 |
try { |
65 |
return Lists.transform(this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query), new Function<String, WorkflowItem>() { |
|
66 |
|
|
67 |
@Override |
|
68 |
public WorkflowItem apply(final String s) { |
|
69 |
final String[] arr = s.split("==@=="); |
|
70 |
return new WorkflowItem(arr[0].trim(), arr[1].trim(), arr[2].trim(), arr[3].trim().length() > 0); |
|
71 |
} |
|
69 |
return Lists.transform(isClient.find(query), s -> { |
|
70 |
final String[] arr = s.split("==@=="); |
|
71 |
return new WorkflowItem(arr[0].trim(), arr[1].trim(), arr[2].trim(), arr[3].trim().length() > 0); |
|
72 | 72 |
}); |
73 |
} catch (final ISLookUpException e) {
|
|
73 |
} catch (final InformationServiceException e) {
|
|
74 | 74 |
log.error("Error obtaining wfs using query: " + query, e); |
75 | 75 |
return Lists.newArrayList(); |
76 | 76 |
} |
... | ... | |
78 | 78 |
|
79 | 79 |
public String getProfile(final String id) { |
80 | 80 |
try { |
81 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(id);
|
|
82 |
} catch (final ISLookUpException e) {
|
|
81 |
return isClient.getProfile(id);
|
|
82 |
} catch (final InformationServiceException e) {
|
|
83 | 83 |
log.error("Error finding profile: " + id, e); |
84 | 84 |
return null; |
85 | 85 |
} |
86 | 86 |
} |
87 | 87 |
|
88 |
public String getRepoProfile(final String id) throws ISLookUpException {
|
|
88 |
public String getRepoProfile(final String id) throws InformationServiceException {
|
|
89 | 89 |
try { |
90 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(id);
|
|
91 |
} catch (final ISLookUpDocumentNotFoundException e) {
|
|
92 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
|
|
93 |
"collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')/*[.//DATASOURCE_ORIGINAL_ID='" + id + "']"); |
|
90 |
return isClient.getProfile(id);
|
|
91 |
} catch (final InformationServiceException e) {
|
|
92 |
return isClient
|
|
93 |
.findOne("collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')/*[.//DATASOURCE_ORIGINAL_ID='" + id + "']");
|
|
94 | 94 |
} |
95 | 95 |
} |
96 | 96 |
|
... | ... | |
99 | 99 |
+ "where count($x//PARAM[@required='true' and string-length(normalize-space(.)) = 0]) > 0 " + "return $x/@name/string()"; |
100 | 100 |
|
101 | 101 |
try { |
102 |
final List<String> list = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
|
|
102 |
final List<String> list = isClient.find(query);
|
|
103 | 103 |
return Sets.newHashSet(list); |
104 | 104 |
} catch (final Exception e) { |
105 | 105 |
log.error("Error executing xquery: " + query, e); |
... | ... | |
119 | 119 |
|
120 | 120 |
final SAXReader reader = new SAXReader(); |
121 | 121 |
|
122 |
for (final String s : this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) {
|
|
122 |
for (final String s : isClient.find(query)) {
|
|
123 | 123 |
final Document doc = reader.read(new StringReader(s)); |
124 | 124 |
final Set<String> ifcTypes = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(doc.valueOf("//TYPES"))); |
125 | 125 |
final Set<String> compliances = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(doc.valueOf("//COMPLIANCES"))); |
... | ... | |
172 | 172 |
final String query = "distinct-values(for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') " |
173 | 173 |
+ "where string-length($x//DATASOURCE/@id) > 0 return $x//WORKFLOW_TYPE/@text())"; |
174 | 174 |
try { |
175 |
return this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
|
|
176 |
} catch (final ISLookUpException e) {
|
|
175 |
return isClient.find(query);
|
|
176 |
} catch (final InformationServiceException e) {
|
|
177 | 177 |
log.error("Error executing xquery: " + query, e); |
178 | 178 |
return Lists.newArrayList(); |
179 | 179 |
} |
... | ... | |
183 | 183 |
final String query = "/*[.//RESOURCE_IDENTIFIER/@value='" + dsId + "']//OFFICIAL_NAME/text()"; |
184 | 184 |
|
185 | 185 |
try { |
186 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query);
|
|
187 |
} catch (final ISLookUpException e) {
|
|
186 |
return isClient.findOne(query);
|
|
187 |
} catch (final InformationServiceException e) {
|
|
188 | 188 |
log.error("Error executing xquery: " + query, e); |
189 | 189 |
return "UNKNOWN"; |
190 | 190 |
} |
... | ... | |
197 | 197 |
final StringTemplate st = new StringTemplate(IOUtils.toString(resource.getInputStream())); |
198 | 198 |
st.setAttribute("wfId", wfId); |
199 | 199 |
|
200 |
final List<String> list = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
|
|
200 |
final List<String> list = isClient.find(st.toString());
|
|
201 | 201 |
final SAXReader reader = new SAXReader(); |
202 | 202 |
return list.stream().map(s -> { |
203 | 203 |
try { |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/clients/ISLookupLightUIClient.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
private static final Log log = LogFactory.getLog(ISLookupLightUIClient.class); |
17 | 17 |
@Autowired |
18 |
private UniqueServiceLocator serviceLocator;
|
|
18 |
private InformationServiceClient isClient;
|
|
19 | 19 |
|
20 | 20 |
public List<LightUiMenuEntry> listMenuEntries() { |
21 | 21 |
final String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') order by $x//UI_NAME " |
22 | 22 |
+ "return concat ($x//UI_NAME/@id, '§§§', $x//UI_NAME, '§§§', $x//UI_DESCRIPTION)"; |
23 | 23 |
List<LightUiMenuEntry> result = new ArrayList<>(); |
24 | 24 |
try { |
25 |
List<String> uiProfiles = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQuery);
|
|
25 |
List<String> uiProfiles = isClient.find(xQuery);
|
|
26 | 26 |
int i = 1; |
27 | 27 |
for (String profile : uiProfiles) { |
28 | 28 |
String[] tokens = profile.split("§§§"); |
... | ... | |
37 | 37 |
|
38 | 38 |
public String getLightUiProfile(final String lightuiId) throws ISLookUpException { |
39 | 39 |
String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') where $x//UI_NAME/@id = '{id}' return $x"; |
40 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery.replace("{id}", lightuiId));
|
|
40 |
return isClient.getProfileByQuery(xQuery.replace("{id}", lightuiId));
|
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java | ||
---|---|---|
4 | 4 |
import java.io.StringReader; |
5 | 5 |
import java.net.HttpURLConnection; |
6 | 6 |
import java.net.URL; |
7 |
import java.util.*; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Collection; |
|
9 |
import java.util.Collections; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
|
|
8 | 13 |
import javax.annotation.Resource; |
9 | 14 |
import javax.servlet.ServletOutputStream; |
10 | 15 |
import javax.servlet.ServletResponse; |
11 | 16 |
import javax.xml.transform.dom.DOMResult; |
12 | 17 |
import javax.xml.xpath.XPathFactory; |
13 | 18 |
|
14 |
import com.google.common.base.Splitter; |
|
15 |
import com.google.common.collect.Iterables; |
|
16 |
import com.google.common.collect.Lists; |
|
17 |
import com.google.common.collect.Maps; |
|
18 |
import eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscription; |
|
19 |
import eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscriptionRegistry; |
|
20 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
21 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
22 |
import eu.dnetlib.functionality.modular.ui.is.bulk.ProfileImporter; |
|
23 |
import eu.dnetlib.functionality.modular.ui.is.objects.*; |
|
24 |
import eu.dnetlib.functionality.modular.ui.is.objects.ServiceDesc.ServiceStatus; |
|
25 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
26 |
import eu.dnetlib.rmi.enabling.ISLookUpDocumentNotFoundException; |
|
27 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
|
28 |
import eu.dnetlib.rmi.enabling.ISLookUpService; |
|
29 |
import eu.dnetlib.rmi.enabling.ISRegistryService; |
|
30 | 19 |
import org.apache.commons.io.IOUtils; |
31 | 20 |
import org.apache.commons.lang3.StringUtils; |
32 | 21 |
import org.apache.commons.lang3.math.NumberUtils; |
... | ... | |
40 | 29 |
import org.springframework.web.bind.annotation.RequestParam; |
41 | 30 |
import org.springframework.web.bind.annotation.ResponseBody; |
42 | 31 |
|
32 |
import com.google.common.base.Splitter; |
|
33 |
import com.google.common.collect.Iterables; |
|
34 |
import com.google.common.collect.Lists; |
|
35 |
import com.google.common.collect.Maps; |
|
36 |
|
|
37 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
38 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
39 |
import eu.dnetlib.functionality.modular.ui.is.bulk.ProfileImporter; |
|
40 |
import eu.dnetlib.functionality.modular.ui.is.objects.CollectionDesc; |
|
41 |
import eu.dnetlib.functionality.modular.ui.is.objects.ServiceDesc; |
|
42 |
import eu.dnetlib.functionality.modular.ui.is.objects.ServiceDesc.ServiceStatus; |
|
43 |
import eu.dnetlib.functionality.modular.ui.is.objects.ServiceGrouperDesc; |
|
44 |
import eu.dnetlib.functionality.modular.ui.is.objects.SubscriptionDesc; |
|
45 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
46 |
|
|
43 | 47 |
@Controller |
44 | 48 |
public class InformationServiceInternalController extends AbstractAjaxController { |
45 | 49 |
|
46 | 50 |
private static final Log log = LogFactory.getLog(InformationServiceInternalController.class); |
47 | 51 |
@Autowired |
48 |
private UniqueServiceLocator serviceLocator;
|
|
52 |
private InformationServiceClient isClient;
|
|
49 | 53 |
@Resource(name = "modularUiProfileImporter") |
50 | 54 |
private ProfileImporter profileImporter; |
51 |
/** |
|
52 |
* is sn subscription registries. |
|
53 |
*/ |
|
54 |
@Resource(name = "issResourceStateNotificationRegistries") |
|
55 |
private transient List<ResourceStateSubscriptionRegistry> registries; |
|
56 | 55 |
|
57 | 56 |
@RequestMapping("/ui/is/xquery.do") |
58 | 57 |
public @ResponseBody List<String> query(@RequestParam(value = "query", required = true) final String query) throws Exception { |
59 | 58 |
log.debug("Executing xquery: " + query); |
60 |
return this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
|
|
59 |
return isClient.find(query);
|
|
61 | 60 |
} |
62 | 61 |
|
63 | 62 |
@RequestMapping("/ui/is/listSchemas.do") |
64 | 63 |
public @ResponseBody List<String> listSchemas() throws Exception { |
65 |
final List<String> list = this.serviceLocator.getService(ISLookUpService.class).listResourceTypes();
|
|
64 |
final List<String> list = isClient.listSchemas();
|
|
66 | 65 |
Collections.sort(list); |
67 | 66 |
return list; |
68 | 67 |
} |
69 | 68 |
|
70 | 69 |
@RequestMapping("/ui/is/getSchema.do") |
71 | 70 |
public @ResponseBody String getSchema(@RequestParam(value = "name", required = true) final String name) throws Exception { |
72 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceTypeSchema(name);
|
|
71 |
return isClient.getSchema(name);
|
|
73 | 72 |
} |
74 | 73 |
|
75 | 74 |
@RequestMapping("/ui/is/listCollections.do") |
... | ... | |
79 | 78 |
"return concat ($kind, ' @@@ ', $type, ' @@@ ', count(xmldb:get-child-resources(concat('/db/DRIVER/', $kind, '/', $type))))"; |
80 | 79 |
|
81 | 80 |
final Map<String, CollectionDesc> map = Maps.newHashMap(); |
82 |
for (final String s : this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
|
|
81 |
for (final String s : isClient.find(xquery)) {
|
|
83 | 82 |
final String[] arr = s.split("@@@"); |
84 | 83 |
final String kind = arr[0].trim(); |
85 | 84 |
final String type = arr[1].trim(); |
... | ... | |
104 | 103 |
@RequestParam(value = "type", required = true) final String type) throws Exception { |
105 | 104 |
final String collName = "/db/DRIVER/" + kind + "/" + type; |
106 | 105 |
final String xquery = "distinct-values(for $x in collection('" + collName + "') return $x//RESOURCE_IDENTIFIER/@value/string())"; |
107 |
final List<String> res = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
|
106 |
final List<String> res = isClient.find(xquery);
|
|
108 | 107 |
|
109 | 108 |
Collections.sort(res); |
110 | 109 |
|
... | ... | |
113 | 112 |
|
114 | 113 |
@RequestMapping("/ui/is/getProfile.do") |
115 | 114 |
public @ResponseBody String getProfiles(@RequestParam(value = "id", required = true) final String id) throws Exception { |
116 |
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(id);
|
|
115 |
return isClient.getProfile(id);
|
|
117 | 116 |
} |
118 | 117 |
|
119 | 118 |
@RequestMapping("/ui/is/registerProfile.do") |
120 | 119 |
public @ResponseBody String registerProfile(@RequestParam(value = "profile", required = true) final String profile) throws Exception { |
121 |
return this.serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
|
|
120 |
return isClient.register(profile);
|
|
122 | 121 |
} |
123 | 122 |
|
124 | 123 |
@RequestMapping("/ui/is/updateProfile.do") |
... | ... | |
127 | 126 |
final Document doc = reader.read(new StringReader(profile)); |
128 | 127 |
|
129 | 128 |
final String id = doc.valueOf("//RESOURCE_IDENTIFIER/@value"); |
130 |
final String type = doc.valueOf("//RESOURCE_TYPE/@value"); |
|
131 | 129 |
|
132 |
if (StringUtils.isEmpty(id)) { |
|
133 |
throw new Exception("RESOURCE_IDENTIFIER is empty"); |
|
134 |
} else if (StringUtils.isEmpty(type)) { |
|
135 |
throw new Exception("RESOURCE_TYPE is empty"); |
|
136 |
} else if (this.serviceLocator.getService(ISRegistryService.class).updateProfile(id, profile, type)) { |
|
137 |
return id; |
|
138 |
} else { |
|
139 |
throw new Exception("Profile not updated"); |
|
140 |
} |
|
130 |
if (StringUtils.isEmpty(id)) { throw new Exception("RESOURCE_IDENTIFIER is empty"); } |
|
131 |
|
|
132 |
isClient.updateProfile(id, profile); |
|
133 |
return id; |
|
141 | 134 |
} |
142 | 135 |
|
143 | 136 |
@RequestMapping("/ui/is/deleteProfile.do") |
144 | 137 |
public @ResponseBody boolean deleteProfile(@RequestParam(value = "id", required = true) final String id) throws Exception { |
145 |
return this.serviceLocator.getService(ISRegistryService.class).deleteProfile(id); |
|
138 |
isClient.deleteProfile(id); |
|
139 |
return true; |
|
146 | 140 |
} |
147 | 141 |
|
148 | 142 |
@RequestMapping("/ui/is/import.do") |
... | ... | |
155 | 149 |
|
156 | 150 |
final Map<String, Integer> res = Maps.newHashMap(); |
157 | 151 |
if (schemas) { |
158 |
res.putAll(this.profileImporter.importSchemas(path + "/**/*.xsd"));
|
|
152 |
res.putAll(profileImporter.importSchemas(path + "/**/*.xsd")); |
|
159 | 153 |
} |
160 | 154 |
if (profiles) { |
161 |
res.putAll(this.profileImporter.importProfiles(path + "/**/*.xml"));
|
|
155 |
res.putAll(profileImporter.importProfiles(path + "/**/*.xml")); |
|
162 | 156 |
} |
163 | 157 |
|
164 | 158 |
return res; |
165 | 159 |
} |
166 | 160 |
|
167 |
@RequestMapping("/ui/is/listBlackboards.do") |
|
168 |
public @ResponseBody List<BlackboardMessage> listBlackboards() throws Exception { |
|
169 |
final List<BlackboardMessage> list = Lists.newArrayList(); |
|
170 |
|
|
171 |
final SAXReader reader = new SAXReader(); |
|
172 |
|
|
173 |
for (final String xml : this.serviceLocator |
|
174 |
.getService(ISLookUpService.class) |
|
175 |
.quickSearchProfile( |
|
176 |
"for $x in collection('/db/DRIVER/ServiceResources')//MESSAGE return <message>{$x/../../..//RESOURCE_TYPE}{$x/../../..//RESOURCE_IDENTIFIER}{$x}</message>")) { |
|
177 |
final BlackboardMessage info = new BlackboardMessage(); |
|
178 |
final Document doc = reader.read(new StringReader(xml)); |
|
179 |
info.setProfId(doc.valueOf(".//RESOURCE_IDENTIFIER/@value")); |
|
180 |
info.setMessageId(doc.valueOf(".//@id")); |
|
181 |
info.setResourceType(doc.valueOf(".//RESOURCE_TYPE/@value")); |
|
182 |
info.setAction(doc.valueOf(".//ACTION")); |
|
183 |
info.setDate(doc.valueOf(".//@date")); |
|
184 |
info.setActionStatus(doc.valueOf(".//ACTION_STATUS")); |
|
185 |
info.setError(doc.valueOf(".//PARAMETER[@name='error']/@value")); |
|
186 |
list.add(info); |
|
187 |
} |
|
188 |
return list; |
|
189 |
} |
|
190 |
|
|
191 | 161 |
@RequestMapping("/ui/is/getMetaWfIdForFamily.do") |
192 |
public @ResponseBody Map<String, String> getMetaWfId(@RequestParam(value = "family", required = true) final String family) throws ISLookUpException {
|
|
162 |
public @ResponseBody Map<String, String> getMetaWfId(@RequestParam(value = "family", required = true) final String family) { |
|
193 | 163 |
final String xq = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') " + |
194 | 164 |
"where $x//METAWORKFLOW_NAME/@family='" + family + "' " + |
195 | 165 |
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//METAWORKFLOW_SECTION)"; |
196 | 166 |
|
197 | 167 |
final Map<String, String> map = Maps.newHashMap(); |
198 | 168 |
try { |
199 |
final String[] arr = this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xq).split("@@@");
|
|
169 |
final String[] arr = isClient.findOne(xq).split("@@@");
|
|
200 | 170 |
map.put("id", arr[0].trim()); |
201 | 171 |
map.put("section", arr[1].trim()); |
202 |
} catch (final ISLookUpDocumentNotFoundException e) {
|
|
172 |
} catch (final Exception e) { |
|
203 | 173 |
map.put("id", ""); |
204 | 174 |
map.put("section", ""); |
205 | 175 |
} |
... | ... | |
215 | 185 |
final List<ServiceDesc> list = Lists.newArrayList(); |
216 | 186 |
|
217 | 187 |
final SAXReader reader = new SAXReader(); |
218 |
for (final String s : this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xq)) {
|
|
188 |
for (final String s : isClient.find(xq)) {
|
|
219 | 189 |
final Document doc = reader.read(new StringReader(s)); |
220 | 190 |
final String id = doc.valueOf("/service/id").trim(); |
221 | 191 |
final String name = doc.valueOf("/service/name").trim(); |
... | ... | |
224 | 194 |
} |
225 | 195 |
|
226 | 196 |
final XPathFactory xpathFactory = XPathFactory.newInstance(); |
227 |
for (final ResourceStateSubscriptionRegistry registry : this.registries) {
|
|
197 |
for (final ResourceStateSubscriptionRegistry registry : registries) { |
|
228 | 198 |
for (final ResourceStateSubscription sub : registry.getSubscriptionDao().listSubscriptions()) { |
229 | 199 |
boolean notFound = true; |
230 | 200 |
final DOMResult result = new DOMResult(); // NOPMD |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/functionality/modular/ui/is/bulk/ProfileImporter.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import com.google.common.collect.Maps; |
18 | 18 |
|
19 |
import eu.dnetlib.enabling.is.store.ISStore; |
|
20 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
21 |
import eu.dnetlib.enabling.tools.StreamOpaqueResource; |
|
22 |
import eu.dnetlib.rmi.enabling.ISRegistryService; |
|
19 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
23 | 20 |
|
24 | 21 |
public class ProfileImporter implements ResourceLoaderAware { |
25 | 22 |
|
... | ... | |
28 | 25 |
private static final Log log = LogFactory.getLog(ProfileImporter.class); |
29 | 26 |
|
30 | 27 |
@Autowired |
31 |
private ISStore isStore;
|
|
28 |
private InformationServiceClient isClient;
|
|
32 | 29 |
|
33 |
@Autowired |
|
34 |
private UniqueServiceLocator serviceLocator; |
|
35 |
|
|
36 | 30 |
public Map<String, Integer> importSchemas(final String path) throws IOException { |
37 | 31 |
|
38 | 32 |
int done = 0; |
... | ... | |
82 | 76 |
|
83 | 77 |
log.info("registering schema: " + resourceType); |
84 | 78 |
|
85 |
this.serviceLocator.getService(ISRegistryService.class).addResourceType(resourceType, IOUtils.toString(url.openStream()));
|
|
79 |
isClient.registerSchema(resourceType, IOUtils.toString(url.openStream()));
|
|
86 | 80 |
} |
87 | 81 |
|
88 | 82 |
private void registerProfile(final URL url) throws Exception { |
... | ... | |
92 | 86 |
|
93 | 87 |
log.info("saving profile: " + name + " in coll " + coll); |
94 | 88 |
|
95 |
this.isStore.insertXML(name, coll, resource.asString());
|
|
89 |
isStore.insertXML(name, coll, resource.asString()); |
|
96 | 90 |
} |
97 | 91 |
|
98 | 92 |
public ResourceLoader getResourceLoader() { |
99 |
return this.resourceLoader;
|
|
93 |
return resourceLoader; |
|
100 | 94 |
} |
101 | 95 |
|
102 | 96 |
@Override |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/pom.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" |
3 | 3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
4 |
|
|
5 |
|
|
6 |
<modelVersion>4.0.0</modelVersion> |
|
7 |
<artifactId>dnet-administration-uis</artifactId> |
|
8 |
<version>0.0.1-SNAPSHOT</version> |
|
9 |
<packaging>jar</packaging> |
|
10 |
|
|
11 |
<name>dnet-administration-uis</name> |
|
12 |
<description>DNet administration UIs</description> |
|
13 |
|
|
4 | 14 |
<parent> |
5 | 15 |
<groupId>eu.dnetlib</groupId> |
6 |
<artifactId>dnet-parent</artifactId>
|
|
7 |
<version>2.0.0-SNAPSHOT</version>
|
|
8 |
<relativePath></relativePath> |
|
16 |
<artifactId>dnet-springboot-apps</artifactId>
|
|
17 |
<version>0.0.1-SNAPSHOT</version>
|
|
18 |
<relativePath>../pom.xml</relativePath>
|
|
9 | 19 |
</parent> |
10 |
<modelVersion>4.0.0</modelVersion> |
|
11 |
<groupId>eu.dnetlib</groupId> |
|
12 |
<artifactId>dnet-modular-uis</artifactId> |
|
13 |
<packaging>jar</packaging> |
|
14 |
<version>1.0.0-SNAPSHOT</version> |
|
15 |
<scm> |
|
16 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet50/modules/dnet-modular-uis/trunk</developerConnection> |
|
17 |
</scm> |
|
18 |
<dependencies> |
|
19 |
<dependency> |
|
20 |
<groupId>eu.dnetlib</groupId> |
|
21 |
<artifactId>dnet-msro-service</artifactId> |
|
22 |
<version>5.0.0-SNAPSHOT</version> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>eu.dnetlib</groupId> |
|
26 |
<artifactId>dnet-information-service</artifactId> |
|
27 |
<version>1.0.0-SNAPSHOT</version> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>eu.dnetlib</groupId> |
|
31 |
<artifactId>dnet-core-components</artifactId> |
|
32 |
<version>1.0.0-SNAPSHOT</version> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.springframework</groupId> |
|
36 |
<artifactId>spring-web</artifactId> |
|
37 |
<version>${spring.version}</version> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.springframework</groupId> |
|
41 |
<artifactId>spring-webmvc</artifactId> |
|
42 |
<version>${spring.version}</version> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.mongodb</groupId> |
|
46 |
<artifactId>mongo-java-driver</artifactId> |
|
47 |
<version>${mongodb.driver.version}</version> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.codehaus.jackson</groupId> |
|
51 |
<artifactId>jackson-mapper-asl</artifactId> |
|
52 |
<version>1.9.13</version> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>javax.servlet</groupId> |
|
56 |
<artifactId>javax.servlet-api</artifactId> |
|
57 |
<version>${javax.servlet.version}</version> |
|
58 |
<scope>provided</scope> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.apache.maven</groupId> |
|
62 |
<artifactId>maven-model</artifactId> |
|
63 |
<version>3.2.3</version> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>junit</groupId> |
|
67 |
<artifactId>junit</artifactId> |
|
68 |
<version>${junit.version}</version> |
|
69 |
<scope>test</scope> |
|
70 |
</dependency> |
|
71 |
<dependency> |
|
72 |
<groupId>eu.dnetlib</groupId> |
|
73 |
<artifactId>dnet-data-provision-services</artifactId> |
|
74 |
<version>1.0.0-SNAPSHOT</version> |
|
75 |
</dependency> |
|
76 |
</dependencies> |
|
77 |
|
|
20 |
|
|
78 | 21 |
<properties> |
79 |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
22 |
<main.basedir>${basedir}/../..</main.basedir>
|
|
80 | 23 |
</properties> |
81 | 24 |
|
25 |
|
|
82 | 26 |
</project> |
Also available in: Unified diff