Revision 47442
Added by Antonis Lempesis almost 7 years ago
modules/uoa-utils/tags/uoa-utils-1.0.0/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U -T 4C source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-utils/trunk", |
|
5 |
"deploy_repository": "dnet4-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", |
|
9 |
"name": "uoa-utils" |
|
10 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/resources/gr/uoa/di/driver/util/springContext-locators.properties | ||
---|---|---|
1 |
ISLookUpService.url= INVALID LINK!!! ISLookUpService |
|
2 |
ISRegistryService.url= INVALID LINK!!! ISRegistryService |
|
3 |
ResultSetService.url= INVALID LINK!!! ResultSetService |
|
4 |
ISSNService.url= INVALID LINK!!! ISSNService |
|
5 |
DBService.url= INVALID LINK!!! DBService |
|
6 |
ActionManagerService.url = INALVID LINK!!! action Service |
|
7 |
A2Service.url= INVALID LINK!!! A2Service |
|
8 |
UserProfileService.url= INVALID LINK!!! UserProfileService |
|
9 |
IndexService.url= INVALID LINK!!! IndexService |
|
10 |
SearchService.url= INVALID LINK!!! SearchService |
|
11 |
CommunityService.url= INVALID LINK!!! CommunityService |
|
12 |
CollectionService.url= INVALID LINK!!! CollectionService |
|
13 |
PublisherService.url= INVALID LINK!!! PublisherService |
|
14 |
RecommendationService.url= INVALID LINK!!! RecommendationService |
|
15 |
ValidatorService.url= INVALID LINK!!! ValidatorService |
|
16 |
ForumService.url = INVALID LINK!!! ForumService |
|
17 |
RatingService.url = INVALID LINK!!! RatingService |
|
18 |
WebInterfaceService.url = INVALID LINK!!! WebInterfaceService |
|
19 |
ValidatorUserInterfaceService.url = INVALID LINK!!! ValidatorUserInterfaceService |
|
20 |
DatasourceManagerService.url = SKATASKATASKATA datasource |
|
21 |
MDStoreService.url = SKATASKATA MDSTORE |
|
22 |
services.similarityService.ws.url = INVALID LINK!!! similarityService |
|
23 |
services.alertService.ws.url = INVALID LINK!!! alertService |
|
24 |
services.notificationService.ws.url = INVALID LINK!!! notificationService |
|
25 |
services.conversionService.ws.url = INVALID LINK!!! conversionService |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/resources/gr/uoa/di/driver/util/springContext-locators.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
4 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
5 |
xmlns:context="http://www.springframework.org/schema/context" |
|
6 |
xmlns:cxf="http://cxf.apache.org/core" |
|
7 |
xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
8 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
9 |
|
|
10 |
xsi:schemaLocation=" |
|
11 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
12 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
|
13 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
|
14 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd" |
|
15 |
default-autowire="byName"> |
|
16 |
|
|
17 |
<bean id="cnr.lookUpLocator" class="eu.dnetlib.enabling.tools.StaticServiceLocator"> |
|
18 |
<property name="service" ref="cnr.lookUpService" /> |
|
19 |
</bean> |
|
20 |
|
|
21 |
<alias name="cnr.lookUpLocator" alias="lookupLocator" /> |
|
22 |
|
|
23 |
<jaxws:client id="cnr.lookUpService" |
|
24 |
serviceClass="eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService" |
|
25 |
address="${ISLookUpService.url}" /> |
|
26 |
|
|
27 |
<bean id="cnr.registryLocator" class="eu.dnetlib.enabling.tools.StaticServiceLocator"> |
|
28 |
<property name="service" ref="cnr.registryService" /> |
|
29 |
</bean> |
|
30 |
|
|
31 |
<alias name="cnr.registryLocator" alias="registryLocator" /> |
|
32 |
|
|
33 |
|
|
34 |
<jaxws:client id="cnr.registryService" |
|
35 |
serviceClass="eu.dnetlib.enabling.is.registry.rmi.ISRegistryService" |
|
36 |
address="${ISRegistryService.url}" /> |
|
37 |
|
|
38 |
<bean id="cnr.snLocator" class="eu.dnetlib.enabling.tools.StaticServiceLocator"> |
|
39 |
<property name="service" ref="cnr.snService" /> |
|
40 |
</bean> |
|
41 |
|
|
42 |
<alias name="cnr.snLocator" alias="snLocator" /> |
|
43 |
|
|
44 |
<jaxws:client id="cnr.snService" |
|
45 |
serviceClass="eu.dnetlib.enabling.is.sn.rmi.ISSNService" |
|
46 |
address="${ISSNService.url}" /> |
|
47 |
|
|
48 |
<!-- The service locators --> |
|
49 |
<bean id="lookupServiceLocator" |
|
50 |
class="eu.dnetlib.clients.utils.ws.JaxwsServiceLocator"> |
|
51 |
<property name="url" value="${ISLookUpService.url}" /> |
|
52 |
<property name="eprBuilder" ref="cxfEndpointReferenceBuilder" /> |
|
53 |
<property name="resolver" ref="serviceResolver" /> |
|
54 |
<property name="serviceClass" value="eu.dnetlib.api.enabling.ISLookUpService" /> |
|
55 |
</bean> |
|
56 |
<bean id="registryServiceLocator" |
|
57 |
factory-bean="serviceLocatorFactory" |
|
58 |
factory-method="newServiceLocator"> |
|
59 |
<constructor-arg value="eu.dnetlib.api.enabling.ISRegistryService" /> |
|
60 |
<constructor-arg value="${ISRegistryService.url}" /> |
|
61 |
</bean> |
|
62 |
<bean id="resultSetServiceLocator" |
|
63 |
factory-bean="serviceLocatorFactory" |
|
64 |
factory-method="newServiceLocator"> |
|
65 |
<constructor-arg value="eu.dnetlib.api.enabling.ResultSetService" /> |
|
66 |
<constructor-arg value="${ResultSetService.url}" /> |
|
67 |
</bean> |
|
68 |
<bean id="subscriptionServiceLocator" |
|
69 |
factory-bean="serviceLocatorFactory" |
|
70 |
factory-method="newServiceLocator"> |
|
71 |
<constructor-arg value="eu.dnetlib.api.enabling.ISSNService" /> |
|
72 |
<constructor-arg value="${ISSNService.url}" /> |
|
73 |
</bean> |
|
74 |
<bean id="datasourceManagerServiceLocator" |
|
75 |
factory-bean="serviceLocatorFactory" |
|
76 |
factory-method="newServiceLocator"> |
|
77 |
<constructor-arg value="eu.dnetlib.api.data.DatasourceManagerService" /> |
|
78 |
<constructor-arg value="${DatasourceManagerService.url}" /> |
|
79 |
</bean> |
|
80 |
<bean id="mdStoreServiceLocator" |
|
81 |
factory-bean="serviceLocatorFactory" |
|
82 |
factory-method="newServiceLocator"> |
|
83 |
<constructor-arg value="eu.dnetlib.api.data.MDStoreService" /> |
|
84 |
<constructor-arg value="${MDStoreService.url}" /> |
|
85 |
</bean> |
|
86 |
<bean id="dbServiceLocator" |
|
87 |
factory-bean="serviceLocatorFactory" |
|
88 |
factory-method="newServiceLocator"> |
|
89 |
<constructor-arg value="eu.dnetlib.api.enabling.DatabaseService" /> |
|
90 |
<constructor-arg value="${DBService.url}" /> |
|
91 |
</bean> |
|
92 |
<bean id="actionManagerLocator" |
|
93 |
factory-bean="serviceLocatorFactory" |
|
94 |
factory-method="newServiceLocator"> |
|
95 |
<constructor-arg value="eu.dnetlib.api.enabling.ActionManagerService" /> |
|
96 |
<constructor-arg value="${ActionManagerService.url}" /> |
|
97 |
</bean> |
|
98 |
<bean id="a2ServiceLocator" |
|
99 |
factory-bean="serviceLocatorFactory" |
|
100 |
factory-method="newServiceLocator"> |
|
101 |
<constructor-arg value="eu.dnetlib.api.enabling.A2Service" /> |
|
102 |
<constructor-arg value="${A2Service.url}" /> |
|
103 |
</bean> |
|
104 |
<bean id="userProfileServiceLocator" |
|
105 |
factory-bean="serviceLocatorFactory" |
|
106 |
factory-method="newServiceLocator"> |
|
107 |
<constructor-arg value="eu.dnetlib.api.functionality.UserProfileService" /> |
|
108 |
<constructor-arg value="${UserProfileService.url}" /> |
|
109 |
</bean> |
|
110 |
<bean id="indexServiceLocator" |
|
111 |
factory-bean="serviceLocatorFactory" |
|
112 |
factory-method="newServiceLocator"> |
|
113 |
<constructor-arg value="eu.dnetlib.api.data.IndexService" /> |
|
114 |
<constructor-arg value="${IndexService.url}" /> |
|
115 |
</bean> |
|
116 |
<bean id="searchServiceLocator" |
|
117 |
factory-bean="serviceLocatorFactory" |
|
118 |
factory-method="newServiceLocator"> |
|
119 |
<constructor-arg value="eu.dnetlib.api.data.SearchService" /> |
|
120 |
<constructor-arg value="${SearchService.url}" /> |
|
121 |
</bean> |
|
122 |
<bean id="communityServiceLocator" |
|
123 |
factory-bean="serviceLocatorFactory" |
|
124 |
factory-method="newServiceLocator"> |
|
125 |
<constructor-arg value="eu.dnetlib.api.functionality.CommunityService" /> |
|
126 |
<constructor-arg value="${CommunityService.url}" /> |
|
127 |
</bean> |
|
128 |
<bean id="collectionServiceLocator" |
|
129 |
factory-bean="serviceLocatorFactory" |
|
130 |
factory-method="newServiceLocator"> |
|
131 |
<constructor-arg value="eu.dnetlib.api.functionality.CollectionService" /> |
|
132 |
<constructor-arg value="${CollectionService.url}" /> |
|
133 |
</bean> |
|
134 |
<bean id="conversionServiceLocator" |
|
135 |
factory-bean="serviceLocatorFactory" |
|
136 |
factory-method="newServiceLocator"> |
|
137 |
<constructor-arg value="eu.dnetlib.api.functionality.ConversionService" /> |
|
138 |
<constructor-arg value="${services.conversionService.ws.url}" /> |
|
139 |
</bean> |
|
140 |
<bean id="publisherServiceLocator" |
|
141 |
factory-bean="serviceLocatorFactory" |
|
142 |
factory-method="newServiceLocator"> |
|
143 |
<constructor-arg value="eu.dnetlib.api.data.PublisherService" /> |
|
144 |
<constructor-arg value="${PublisherService.url}" /> |
|
145 |
</bean> |
|
146 |
<bean id="recommendationServiceLocator" |
|
147 |
factory-bean="serviceLocatorFactory" |
|
148 |
factory-method="newServiceLocator"> |
|
149 |
<constructor-arg value="eu.dnetlib.api.functionality.RecommendationService" /> |
|
150 |
<constructor-arg value="${RecommendationService.url}" /> |
|
151 |
</bean> |
|
152 |
<bean id="validatorServiceLocator" |
|
153 |
factory-bean="serviceLocatorFactory" |
|
154 |
factory-method="newServiceLocator"> |
|
155 |
<constructor-arg value="eu.dnetlib.api.functionality.ValidatorService" /> |
|
156 |
<constructor-arg value="${ValidatorService.url}" /> |
|
157 |
</bean> |
|
158 |
<bean id="forumServiceLocator" |
|
159 |
factory-bean="serviceLocatorFactory" |
|
160 |
factory-method="newServiceLocator"> |
|
161 |
<constructor-arg value="eu.dnetlib.api.functionality.ForumService" /> |
|
162 |
<constructor-arg value="${ForumService.url}" /> |
|
163 |
</bean> |
|
164 |
<bean id="ratingServiceLocator" |
|
165 |
factory-bean="serviceLocatorFactory" |
|
166 |
factory-method="newServiceLocator"> |
|
167 |
<constructor-arg value="eu.dnetlib.api.functionality.RatingService" /> |
|
168 |
<constructor-arg value="${RatingService.url}" /> |
|
169 |
</bean> |
|
170 |
<bean id="webIntarfaceServiceLocator" |
|
171 |
factory-bean="serviceLocatorFactory" |
|
172 |
factory-method="newServiceLocator"> |
|
173 |
<constructor-arg value="eu.dnetlib.api.functionality.WebInterfaceService" /> |
|
174 |
<constructor-arg value="${WebInterfaceService.url}" /> |
|
175 |
</bean> |
|
176 |
<bean id="validatorWebServiceLocator" |
|
177 |
factory-bean="serviceLocatorFactory" |
|
178 |
factory-method="newServiceLocator"> |
|
179 |
<constructor-arg value="eu.dnetlib.api.functionality.ValidatorUserInterfaceService" /> |
|
180 |
<constructor-arg value="${ValidatorUserInterfaceService.url}" /> |
|
181 |
</bean> |
|
182 |
<bean id="similarityServiceLocator" |
|
183 |
factory-bean="serviceLocatorFactory" |
|
184 |
factory-method="newServiceLocator"> |
|
185 |
<constructor-arg value="eu.dnetlib.api.data.SimilarityService" /> |
|
186 |
<constructor-arg value="${services.similarityService.ws.url}" /> |
|
187 |
</bean> |
|
188 |
<bean id="alertServiceLocator" |
|
189 |
factory-bean="serviceLocatorFactory" |
|
190 |
factory-method="newServiceLocator"> |
|
191 |
<constructor-arg value="eu.dnetlib.api.functionality.AlertService" /> |
|
192 |
<constructor-arg value="${services.alertService.ws.url}" /> |
|
193 |
</bean> |
|
194 |
<bean id="notificationServiceLocator" |
|
195 |
factory-bean="serviceLocatorFactory" |
|
196 |
factory-method="newServiceLocator"> |
|
197 |
<constructor-arg value="eu.dnetlib.api.functionality.NotificationService" /> |
|
198 |
<constructor-arg value="${services.notificationService.ws.url}" /> |
|
199 |
</bean> |
|
200 |
</beans> |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/ServiceLocatorFactory.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import eu.dnetlib.api.DriverService; |
|
4 |
|
|
5 |
/** |
|
6 |
* A factory to create service locators. |
|
7 |
* |
|
8 |
* @author <a href="mailto:antleb@di.uoa.gr">Antonis Lempesis</a> |
|
9 |
* |
|
10 |
*/ |
|
11 |
public interface ServiceLocatorFactory { |
|
12 |
|
|
13 |
/** |
|
14 |
* Creates a dynamic service locator. |
|
15 |
* |
|
16 |
* @param <S> the service type. |
|
17 |
* @param serviceClass the service class. |
|
18 |
* @return A service locator for services of type S. |
|
19 |
*/ |
|
20 |
public <S extends DriverService> ServiceLocator<S> newServiceLocator( |
|
21 |
Class<S> serviceClass); |
|
22 |
|
|
23 |
/** |
|
24 |
* Creates a service locator. It can be either static (if serviceUrl != null) |
|
25 |
* or dynamic. |
|
26 |
* |
|
27 |
* @param <S> the service type. |
|
28 |
* @param serviceClass the service class. |
|
29 |
* @param serviceUrl The service URL. |
|
30 |
* @return A service locator for services of type S. |
|
31 |
*/ |
|
32 |
public <S extends DriverService> ServiceLocator<S> newServiceLocator( |
|
33 |
Class<S> serviceClass, String serviceUrl); |
|
34 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/StaticServiceLocator.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import eu.dnetlib.api.DriverService; |
|
4 |
|
|
5 |
/** |
|
6 |
* An implementation of the ServiceLocator that returns a predefined instance |
|
7 |
* of a service. |
|
8 |
* |
|
9 |
* Can be used for debug purposes, FallBackLocator or when 2 services A and B |
|
10 |
* are deployed in the same application (in this case, service A will get an |
|
11 |
* instance of a StaticServiceLocator<B> in order to avoid calls to the IS and |
|
12 |
* traversing the whole SOAP stack in order to communicate with B). |
|
13 |
* |
|
14 |
* @author <a href="mailto:antleb@di.uoa.gr">Antonis Lempesis</a> |
|
15 |
* |
|
16 |
* @param <S> |
|
17 |
*/ |
|
18 |
public class StaticServiceLocator<S extends DriverService> |
|
19 |
implements ServiceLocator<S> { |
|
20 |
|
|
21 |
private S service = null; |
|
22 |
|
|
23 |
public StaticServiceLocator() { |
|
24 |
|
|
25 |
} |
|
26 |
|
|
27 |
public StaticServiceLocator(S service) { |
|
28 |
this.service = service; |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public S getService() { |
|
33 |
return service; |
|
34 |
} |
|
35 |
|
|
36 |
public void setService(S service) { |
|
37 |
this.service = service; |
|
38 |
} |
|
39 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/RefreshingServiceLocator.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import java.util.concurrent.ScheduledExecutorService; |
|
4 |
import java.util.concurrent.TimeUnit; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
|
|
8 |
import eu.dnetlib.api.DriverService; |
|
9 |
|
|
10 |
/** |
|
11 |
* An implementation of the service locator that keeps a cache of the service |
|
12 |
* and refreshes it periodically. |
|
13 |
* |
|
14 |
* The actual task of service discovery is performed by a locator that is |
|
15 |
* injected. |
|
16 |
* |
|
17 |
* @author <a href="mailto:antleb@di.uoa.gr">Antonis Lempesis</a> |
|
18 |
* |
|
19 |
* @param <S> the service type |
|
20 |
*/ |
|
21 |
public class RefreshingServiceLocator<S extends DriverService> implements |
|
22 |
ServiceLocator<S> { |
|
23 |
/** The locator used to discover the service */ |
|
24 |
private ServiceLocator<S> locator = null; |
|
25 |
/** the cached instance of the service */ |
|
26 |
private S service = null; |
|
27 |
/** the executor that runs the refresh tasks */ |
|
28 |
private ScheduledExecutorService executor = null; |
|
29 |
/** the discovery period in milliseconds*/ |
|
30 |
private long period = 0; |
|
31 |
|
|
32 |
@Override |
|
33 |
public synchronized S getService() { |
|
34 |
if (service == null) |
|
35 |
init(); |
|
36 |
|
|
37 |
return service; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Called to initialize the locator. Performs the first service lookup and |
|
42 |
* also schedules the periodic refresh of the cache. |
|
43 |
* |
|
44 |
* */ |
|
45 |
private void init() { |
|
46 |
this.service = locator.getService(); |
|
47 |
|
|
48 |
executor.scheduleWithFixedDelay(new RefreshTask(), period, period, |
|
49 |
TimeUnit.MILLISECONDS); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* A very simple runnable that refreshed the cache. No synchronization is |
|
54 |
* needed during cache refresh: The old instance will be returned while the |
|
55 |
* locator is working to refresh the cache. |
|
56 |
* |
|
57 |
* @author <a href="mailto:antleb@di.uoa.gr">Antonis Lempesis</a> |
|
58 |
* |
|
59 |
*/ |
|
60 |
private class RefreshTask implements Runnable { |
|
61 |
private Logger logger = Logger.getLogger(RefreshTask.class); |
|
62 |
|
|
63 |
@Override |
|
64 |
public void run() { |
|
65 |
try { |
|
66 |
logger.debug("Refreshing service cache"); |
|
67 |
service = locator.getService(); |
|
68 |
} catch (Exception e) { |
|
69 |
logger.info("Error refreshing service", e); |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
public ServiceLocator<S> getLocator() { |
|
75 |
return locator; |
|
76 |
} |
|
77 |
|
|
78 |
public void setLocator(ServiceLocator<S> locator) { |
|
79 |
this.locator = locator; |
|
80 |
} |
|
81 |
|
|
82 |
public ScheduledExecutorService getExecutor() { |
|
83 |
return executor; |
|
84 |
} |
|
85 |
|
|
86 |
public void setExecutor(ScheduledExecutorService executor) { |
|
87 |
this.executor = executor; |
|
88 |
} |
|
89 |
|
|
90 |
public long getPeriod() { |
|
91 |
return period; |
|
92 |
} |
|
93 |
|
|
94 |
public void setPeriod(long period) { |
|
95 |
this.period = period; |
|
96 |
} |
|
97 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/FallBackServiceLocator.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import eu.dnetlib.api.DriverService; |
|
4 |
|
|
5 |
public class FallBackServiceLocator<S extends DriverService> |
|
6 |
implements ServiceLocator<S> { |
|
7 |
|
|
8 |
private ServiceLocator<S> mainLocator = null; |
|
9 |
private ServiceLocator<S> fallBackLocator = null; |
|
10 |
|
|
11 |
@Override |
|
12 |
public S getService() { |
|
13 |
S service = null; |
|
14 |
|
|
15 |
if (mainLocator != null) |
|
16 |
service = mainLocator.getService(); |
|
17 |
|
|
18 |
if (service == null && fallBackLocator != null) |
|
19 |
service = fallBackLocator.getService(); |
|
20 |
|
|
21 |
return service; |
|
22 |
} |
|
23 |
|
|
24 |
public FallBackServiceLocator(ServiceLocator<S> mainLocator, |
|
25 |
ServiceLocator<S> fallBackLocator) { |
|
26 |
this.mainLocator = mainLocator; |
|
27 |
this.fallBackLocator = fallBackLocator; |
|
28 |
} |
|
29 |
|
|
30 |
public void setMainLocator(ServiceLocator<S> mainLocator) { |
|
31 |
this.mainLocator = mainLocator; |
|
32 |
} |
|
33 |
|
|
34 |
public void setFallBackLocator(ServiceLocator<S> fallBackLocator) { |
|
35 |
this.fallBackLocator = fallBackLocator; |
|
36 |
} |
|
37 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/ServiceLocator.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import eu.dnetlib.api.DriverService; |
|
4 |
|
|
5 |
public interface ServiceLocator<S extends DriverService> { |
|
6 |
|
|
7 |
public S getService(); |
|
8 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/gr/uoa/di/driver/util/ServiceNameResolverImpl.java | ||
---|---|---|
1 |
package gr.uoa.di.driver.util; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import eu.dnetlib.api.DriverService; |
|
7 |
import eu.dnetlib.enabling.tools.registration.ServiceNameResolver; |
|
8 |
|
|
9 |
public class ServiceNameResolverImpl implements ServiceNameResolver { |
|
10 |
private Map<Class<?>, String> override = new HashMap<Class<?>, String>(); |
|
11 |
|
|
12 |
@Override |
|
13 |
public String getName(Object service) { |
|
14 |
return getName(service.getClass()); |
|
15 |
} |
|
16 |
|
|
17 |
@Override |
|
18 |
public String getName(Class<?> serviceInterface) { |
|
19 |
String serviceName = null; |
|
20 |
|
|
21 |
for (Class<?> i : serviceInterface.getInterfaces()) { |
|
22 |
if (DriverService.class.isAssignableFrom(i)) { |
|
23 |
if (override.get(i) != null) |
|
24 |
serviceName = override.get(i); |
|
25 |
else |
|
26 |
serviceName = i.getSimpleName(); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
return serviceName; |
|
31 |
} |
|
32 |
|
|
33 |
public Map<Class<?>, String> getOverride() { |
|
34 |
return override; |
|
35 |
} |
|
36 |
|
|
37 |
public void setOverride(Map<Class<?>, String> override) { |
|
38 |
this.override = override; |
|
39 |
} |
|
40 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/eu/dnetlib/utils/cql/CqlQuery.java | ||
---|---|---|
1 |
package eu.dnetlib.utils.cql; |
|
2 |
|
|
3 |
import static eu.dnetlib.utils.cql.CqlClause.CqlClauseType.BOOLEAN; |
|
4 |
import static eu.dnetlib.utils.cql.CqlClause.CqlClauseType.RELATION; |
|
5 |
import static eu.dnetlib.utils.cql.CqlClause.CqlClauseType.TERM; |
|
6 |
|
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author stoumpos |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class CqlQuery { |
|
15 |
|
|
16 |
CqlClause root = null; |
|
17 |
|
|
18 |
CqlQuery() { |
|
19 |
this(null); |
|
20 |
} |
|
21 |
|
|
22 |
CqlQuery(CqlClause root) { |
|
23 |
this.root = root; |
|
24 |
} |
|
25 |
|
|
26 |
public CqlClause getRoot() { |
|
27 |
return root; |
|
28 |
} |
|
29 |
|
|
30 |
public void setRoot(CqlClause root) { |
|
31 |
this.root = root; |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public String toString() { |
|
36 |
return (root == null) ? "null" : root.toCqlString(); |
|
37 |
} |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* Return <code>true</code> if this query is a superset of |
|
42 |
* <code>query</code>, otherwise <code>false</code>. |
|
43 |
*/ |
|
44 |
public boolean contains(CqlQuery query) { |
|
45 |
return contains(root, query.getRoot()); |
|
46 |
} |
|
47 |
|
|
48 |
private boolean contains(CqlClause big, CqlClause small) { |
|
49 |
|
|
50 |
if (big.type == BOOLEAN && small.type == BOOLEAN) { |
|
51 |
return containsBooleans((CqlBoolean) big, (CqlBoolean) small); |
|
52 |
|
|
53 |
} else if (big.type == BOOLEAN) { |
|
54 |
// small is either term or relation |
|
55 |
return containsBooleanTerm((CqlBoolean) big, small); |
|
56 |
|
|
57 |
} else if (small.type == BOOLEAN) { |
|
58 |
// big is either term or relation |
|
59 |
return containsTermBoolean(big, (CqlBoolean) small); |
|
60 |
|
|
61 |
} else if (big.type == RELATION && small.type == RELATION) { |
|
62 |
CqlRelation bigRelation = (CqlRelation) big; |
|
63 |
CqlRelation smallRelation = (CqlRelation) small; |
|
64 |
return bigRelation.index.equals(smallRelation.index) |
|
65 |
&& bigRelation.operator.equals(smallRelation.operator) |
|
66 |
&& bigRelation.value.equals(smallRelation.value); |
|
67 |
|
|
68 |
} else if (big.type == TERM && small.type == TERM) { |
|
69 |
return ((CqlTerm) big).term.equals(((CqlTerm) small).term); |
|
70 |
} |
|
71 |
|
|
72 |
return false; |
|
73 |
} |
|
74 |
|
|
75 |
private boolean containsBooleans(CqlBoolean a, CqlBoolean b) { |
|
76 |
if (a.getOperator().equalsIgnoreCase(b.getOperator())) { |
|
77 |
|
|
78 |
ArrayList<CqlClause> aList = unfold(a); |
|
79 |
ArrayList<CqlClause> bList = unfold(b); |
|
80 |
|
|
81 |
if (a.operator.equalsIgnoreCase("and")) { |
|
82 |
return subset(aList, bList); |
|
83 |
|
|
84 |
} else if (a.operator.equalsIgnoreCase("or")) { |
|
85 |
return superset(bList, aList); |
|
86 |
|
|
87 |
} else { |
|
88 |
throw new IllegalArgumentException( |
|
89 |
"Unsupported operator: " + a.operator); |
|
90 |
} |
|
91 |
|
|
92 |
} else { |
|
93 |
return contains(a, b.getLeft()) && contains(a, b.getRight()); |
|
94 |
|
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public ArrayList<CqlClause> unfold(CqlBoolean bool) { |
|
99 |
|
|
100 |
String op = bool.operator; |
|
101 |
ArrayList<CqlClause> siblings = new ArrayList<CqlClause>(); |
|
102 |
|
|
103 |
if (bool.left.type == BOOLEAN |
|
104 |
&& ((CqlBoolean) bool.left).operator.equalsIgnoreCase(op)) { |
|
105 |
siblings.addAll(unfold((CqlBoolean) bool.left)); |
|
106 |
} else { |
|
107 |
siblings.add(bool.left); |
|
108 |
} |
|
109 |
|
|
110 |
if (bool.right.type == BOOLEAN |
|
111 |
&& ((CqlBoolean) bool.right).operator.equalsIgnoreCase(op)) { |
|
112 |
siblings.addAll(unfold((CqlBoolean) bool.right)); |
|
113 |
} else { |
|
114 |
siblings.add(bool.right); |
|
115 |
} |
|
116 |
|
|
117 |
return siblings; |
|
118 |
} |
|
119 |
|
|
120 |
|
|
121 |
private boolean superset(List<CqlClause> superset, List<CqlClause> subset) { |
|
122 |
if (subset.size() > superset.size()) { |
|
123 |
return false; |
|
124 |
} |
|
125 |
for (CqlClause sub : subset) { |
|
126 |
boolean found = false; |
|
127 |
for (CqlClause sup : superset) { |
|
128 |
if (contains(sup, sub)) { |
|
129 |
found = true; |
|
130 |
break; |
|
131 |
} |
|
132 |
} |
|
133 |
if (!found) { |
|
134 |
return false; |
|
135 |
} |
|
136 |
} |
|
137 |
return true; |
|
138 |
} |
|
139 |
|
|
140 |
private boolean subset(List<CqlClause> subset, List<CqlClause> superset) { |
|
141 |
if (subset.size() > superset.size()) { |
|
142 |
return false; |
|
143 |
} |
|
144 |
for (CqlClause sub : subset) { |
|
145 |
boolean found = false; |
|
146 |
for (CqlClause sup : superset) { |
|
147 |
if (contains(sub, sup)) { |
|
148 |
found = true; |
|
149 |
break; |
|
150 |
} |
|
151 |
} |
|
152 |
if (!found) { |
|
153 |
return false; |
|
154 |
} |
|
155 |
} |
|
156 |
return true; |
|
157 |
} |
|
158 |
|
|
159 |
private boolean containsBooleanTerm(CqlBoolean bool, CqlClause clause) { |
|
160 |
|
|
161 |
if (bool.getOperator().equalsIgnoreCase("and")) { |
|
162 |
// warn: assume clause is either term or relation |
|
163 |
return false; |
|
164 |
} |
|
165 |
|
|
166 |
return contains(bool.getLeft(), clause) |
|
167 |
|| contains(bool.getRight(), clause); |
|
168 |
} |
|
169 |
|
|
170 |
private boolean containsTermBoolean(CqlClause clause, CqlBoolean bool) { |
|
171 |
|
|
172 |
if (bool.getOperator().equalsIgnoreCase("or")) { |
|
173 |
// warn: assume clause is either term or relation |
|
174 |
return false; |
|
175 |
} |
|
176 |
|
|
177 |
return contains(clause, bool.getLeft()) |
|
178 |
|| contains(clause, bool.getRight()); |
|
179 |
} |
|
180 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/eu/dnetlib/utils/cql/CqlTerm.java | ||
---|---|---|
1 |
package eu.dnetlib.utils.cql; |
|
2 |
|
|
3 |
|
|
4 |
/** |
|
5 |
* @author stoumpos |
|
6 |
* |
|
7 |
*/ |
|
8 |
public class CqlTerm extends CqlClause { |
|
9 |
|
|
10 |
String term = null; |
|
11 |
|
|
12 |
public CqlTerm() { |
|
13 |
this(null); |
|
14 |
} |
|
15 |
|
|
16 |
public CqlTerm(String term) { |
|
17 |
super(CqlClauseType.TERM); |
|
18 |
this.term = term; |
|
19 |
} |
|
20 |
|
|
21 |
public String getTerm() { |
|
22 |
return term; |
|
23 |
} |
|
24 |
|
|
25 |
public void setTerm(String term) { |
|
26 |
this.term = term; |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
public String toCqlString() { |
|
31 |
return term; |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public String toNodeString(String prefix) { |
|
36 |
return prefix + "term: " + toCqlString(); |
|
37 |
} |
|
38 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/eu/dnetlib/utils/cql/CqlClause.java | ||
---|---|---|
1 |
package eu.dnetlib.utils.cql; |
|
2 |
|
|
3 |
/** |
|
4 |
* @author stoumpos |
|
5 |
* |
|
6 |
*/ |
|
7 |
public abstract class CqlClause |
|
8 |
{ |
|
9 |
public static enum CqlClauseType { BOOLEAN, RELATION, TERM }; |
|
10 |
|
|
11 |
public final CqlClauseType type; |
|
12 |
|
|
13 |
CqlClause(CqlClauseType type) { |
|
14 |
super(); |
|
15 |
this.type = type; |
|
16 |
} |
|
17 |
|
|
18 |
@Override |
|
19 |
public String toString() |
|
20 |
{ |
|
21 |
return toCqlString(); |
|
22 |
} |
|
23 |
|
|
24 |
public abstract String toCqlString(); |
|
25 |
|
|
26 |
public abstract String toNodeString(String prefix); |
|
27 |
} |
modules/uoa-utils/tags/uoa-utils-1.0.0/src/main/java/eu/dnetlib/utils/cql/CqlParser.java | ||
---|---|---|
1 |
// $ANTLR 3.0.1 Cql.g3 2013-07-19 13:56:26 |
|
2 |
|
|
3 |
package eu.dnetlib.utils.cql; |
|
4 |
|
|
5 |
|
|
6 |
import org.antlr.runtime.*; |
|
7 |
import java.util.Stack; |
|
8 |
import java.util.List; |
|
9 |
import java.util.ArrayList; |
|
10 |
|
|
11 |
|
|
12 |
import org.antlr.runtime.tree.*; |
|
13 |
|
|
14 |
public class CqlParser extends Parser { |
|
15 |
public static final String[] tokenNames = new String[] { |
|
16 |
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "AND", "OR", "NOT", "PROX", "WITHIN", "EXACT", "ALL", "ANY", "IDENTIFIER", "STRING", "QUOTE", "WHITESPACE", "'>'", "'='", "'/'", "'('", "')'", "'<'", "'>='", "'<='", "'<>'" |
|
17 |
}; |
|
18 |
public static final int QUOTE=14; |
|
19 |
public static final int ANY=11; |
|
20 |
public static final int IDENTIFIER=12; |
|
21 |
public static final int ALL=10; |
|
22 |
public static final int OR=5; |
|
23 |
public static final int WITHIN=8; |
|
24 |
public static final int PROX=7; |
|
25 |
public static final int WHITESPACE=15; |
|
26 |
public static final int EXACT=9; |
|
27 |
public static final int NOT=6; |
|
28 |
public static final int AND=4; |
|
29 |
public static final int EOF=-1; |
|
30 |
public static final int STRING=13; |
|
31 |
|
|
32 |
public CqlParser(TokenStream input) { |
|
33 |
super(input); |
|
34 |
} |
|
35 |
|
|
36 |
protected TreeAdaptor adaptor = new CommonTreeAdaptor(); |
|
37 |
|
|
38 |
public void setTreeAdaptor(TreeAdaptor adaptor) { |
|
39 |
this.adaptor = adaptor; |
|
40 |
} |
|
41 |
public TreeAdaptor getTreeAdaptor() { |
|
42 |
return adaptor; |
|
43 |
} |
|
44 |
|
|
45 |
public String[] getTokenNames() { return tokenNames; } |
|
46 |
public String getGrammarFileName() { return "Cql.g3"; } |
|
47 |
|
|
48 |
|
|
49 |
@Override |
|
50 |
public void reportError(RecognitionException e) { |
|
51 |
throw new CqlRuntimeException("Parser Error", e); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
public static class cql_return extends ParserRuleReturnScope { |
|
56 |
public CqlQuery query; |
|
57 |
CommonTree tree; |
|
58 |
public Object getTree() { return tree; } |
|
59 |
}; |
|
60 |
|
|
61 |
// $ANTLR start cql |
|
62 |
// Cql.g3:33:1: cql returns [CqlQuery query] : q= cqlquery ; |
|
63 |
public final cql_return cql() throws RecognitionException { |
|
64 |
cql_return retval = new cql_return(); |
|
65 |
retval.start = input.LT(1); |
|
66 |
|
|
67 |
CommonTree root_0 = null; |
|
68 |
|
|
69 |
cqlquery_return q = null; |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
try { |
|
74 |
// Cql.g3:33:30: (q= cqlquery ) |
|
75 |
// Cql.g3:33:32: q= cqlquery |
|
76 |
{ |
|
77 |
root_0 = (CommonTree)adaptor.nil(); |
|
78 |
|
|
79 |
pushFollow(FOLLOW_cqlquery_in_cql78); |
|
80 |
q=cqlquery(); |
|
81 |
_fsp--; |
|
82 |
|
|
83 |
adaptor.addChild(root_0, q.getTree()); |
|
84 |
|
|
85 |
//System.out.println("query tree: " + |
|
86 |
// ((CommonTree)q.tree).toStringTree() ); |
|
87 |
retval.query = q.query; |
|
88 |
|
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
retval.stop = input.LT(-1); |
|
93 |
|
|
94 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
95 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
96 |
|
|
97 |
} |
|
98 |
catch (RecognitionException re) { |
|
99 |
reportError(re); |
|
100 |
recover(input,re); |
|
101 |
} |
|
102 |
finally { |
|
103 |
} |
|
104 |
return retval; |
|
105 |
} |
|
106 |
// $ANTLR end cql |
|
107 |
|
|
108 |
public static class cqlquery_return extends ParserRuleReturnScope { |
|
109 |
public CqlQuery query; |
|
110 |
CommonTree tree; |
|
111 |
public Object getTree() { return tree; } |
|
112 |
}; |
|
113 |
|
|
114 |
// $ANTLR start cqlquery |
|
115 |
// Cql.g3:41:1: cqlquery returns [CqlQuery query] : ( qscope q= cqlquery | c= scopedClause ); |
|
116 |
public final cqlquery_return cqlquery() throws RecognitionException { |
|
117 |
cqlquery_return retval = new cqlquery_return(); |
|
118 |
retval.start = input.LT(1); |
|
119 |
|
|
120 |
CommonTree root_0 = null; |
|
121 |
|
|
122 |
cqlquery_return q = null; |
|
123 |
|
|
124 |
scopedClause_return c = null; |
|
125 |
|
|
126 |
qscope_return qscope1 = null; |
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
try { |
|
131 |
// Cql.g3:42:5: ( qscope q= cqlquery | c= scopedClause ) |
|
132 |
int alt1=2; |
|
133 |
int LA1_0 = input.LA(1); |
|
134 |
|
|
135 |
if ( (LA1_0==16) ) { |
|
136 |
alt1=1; |
|
137 |
} |
|
138 |
else if ( ((LA1_0>=AND && LA1_0<=PROX)||(LA1_0>=IDENTIFIER && LA1_0<=STRING)||LA1_0==19) ) { |
|
139 |
alt1=2; |
|
140 |
} |
|
141 |
else { |
|
142 |
NoViableAltException nvae = |
|
143 |
new NoViableAltException("41:1: cqlquery returns [CqlQuery query] : ( qscope q= cqlquery | c= scopedClause );", 1, 0, input); |
|
144 |
|
|
145 |
throw nvae; |
|
146 |
} |
|
147 |
switch (alt1) { |
|
148 |
case 1 : |
|
149 |
// Cql.g3:42:7: qscope q= cqlquery |
|
150 |
{ |
|
151 |
root_0 = (CommonTree)adaptor.nil(); |
|
152 |
|
|
153 |
pushFollow(FOLLOW_qscope_in_cqlquery104); |
|
154 |
qscope1=qscope(); |
|
155 |
_fsp--; |
|
156 |
|
|
157 |
pushFollow(FOLLOW_cqlquery_in_cqlquery109); |
|
158 |
q=cqlquery(); |
|
159 |
_fsp--; |
|
160 |
|
|
161 |
adaptor.addChild(root_0, q.getTree()); |
|
162 |
retval.query = q.query; |
|
163 |
|
|
164 |
} |
|
165 |
break; |
|
166 |
case 2 : |
|
167 |
// Cql.g3:43:7: c= scopedClause |
|
168 |
{ |
|
169 |
root_0 = (CommonTree)adaptor.nil(); |
|
170 |
|
|
171 |
pushFollow(FOLLOW_scopedClause_in_cqlquery121); |
|
172 |
c=scopedClause(); |
|
173 |
_fsp--; |
|
174 |
|
|
175 |
adaptor.addChild(root_0, c.getTree()); |
|
176 |
retval.query = new CqlQuery(c.clause); |
|
177 |
|
|
178 |
} |
|
179 |
break; |
|
180 |
|
|
181 |
} |
|
182 |
retval.stop = input.LT(-1); |
|
183 |
|
|
184 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
185 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
186 |
|
|
187 |
} |
|
188 |
catch (RecognitionException re) { |
|
189 |
reportError(re); |
|
190 |
recover(input,re); |
|
191 |
} |
|
192 |
finally { |
|
193 |
} |
|
194 |
return retval; |
|
195 |
} |
|
196 |
// $ANTLR end cqlquery |
|
197 |
|
|
198 |
public static class qscope_return extends ParserRuleReturnScope { |
|
199 |
CommonTree tree; |
|
200 |
public Object getTree() { return tree; } |
|
201 |
}; |
|
202 |
|
|
203 |
// $ANTLR start qscope |
|
204 |
// Cql.g3:45:1: qscope : ( '>' prefix '=' uri | '>' uri ); |
|
205 |
public final qscope_return qscope() throws RecognitionException { |
|
206 |
qscope_return retval = new qscope_return(); |
|
207 |
retval.start = input.LT(1); |
|
208 |
|
|
209 |
CommonTree root_0 = null; |
|
210 |
|
|
211 |
Token char_literal2=null; |
|
212 |
Token char_literal4=null; |
|
213 |
Token char_literal6=null; |
|
214 |
prefix_return prefix3 = null; |
|
215 |
|
|
216 |
uri_return uri5 = null; |
|
217 |
|
|
218 |
uri_return uri7 = null; |
|
219 |
|
|
220 |
|
|
221 |
CommonTree char_literal2_tree=null; |
|
222 |
CommonTree char_literal4_tree=null; |
|
223 |
CommonTree char_literal6_tree=null; |
|
224 |
|
|
225 |
try { |
|
226 |
// Cql.g3:47:9: ( '>' prefix '=' uri | '>' uri ) |
|
227 |
int alt2=2; |
|
228 |
int LA2_0 = input.LA(1); |
|
229 |
|
|
230 |
if ( (LA2_0==16) ) { |
|
231 |
switch ( input.LA(2) ) { |
|
232 |
case IDENTIFIER: |
|
233 |
{ |
|
234 |
int LA2_2 = input.LA(3); |
|
235 |
|
|
236 |
if ( ((LA2_2>=AND && LA2_2<=PROX)||(LA2_2>=IDENTIFIER && LA2_2<=STRING)||LA2_2==16||LA2_2==19) ) { |
|
237 |
alt2=2; |
|
238 |
} |
|
239 |
else if ( (LA2_2==17) ) { |
|
240 |
alt2=1; |
|
241 |
} |
|
242 |
else { |
|
243 |
NoViableAltException nvae = |
|
244 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 2, input); |
|
245 |
|
|
246 |
throw nvae; |
|
247 |
} |
|
248 |
} |
|
249 |
break; |
|
250 |
case STRING: |
|
251 |
{ |
|
252 |
int LA2_3 = input.LA(3); |
|
253 |
|
|
254 |
if ( ((LA2_3>=AND && LA2_3<=PROX)||(LA2_3>=IDENTIFIER && LA2_3<=STRING)||LA2_3==16||LA2_3==19) ) { |
|
255 |
alt2=2; |
|
256 |
} |
|
257 |
else if ( (LA2_3==17) ) { |
|
258 |
alt2=1; |
|
259 |
} |
|
260 |
else { |
|
261 |
NoViableAltException nvae = |
|
262 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 3, input); |
|
263 |
|
|
264 |
throw nvae; |
|
265 |
} |
|
266 |
} |
|
267 |
break; |
|
268 |
case AND: |
|
269 |
{ |
|
270 |
int LA2_4 = input.LA(3); |
|
271 |
|
|
272 |
if ( (LA2_4==17) ) { |
|
273 |
alt2=1; |
|
274 |
} |
|
275 |
else if ( ((LA2_4>=AND && LA2_4<=PROX)||(LA2_4>=IDENTIFIER && LA2_4<=STRING)||LA2_4==16||LA2_4==19) ) { |
|
276 |
alt2=2; |
|
277 |
} |
|
278 |
else { |
|
279 |
NoViableAltException nvae = |
|
280 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 4, input); |
|
281 |
|
|
282 |
throw nvae; |
|
283 |
} |
|
284 |
} |
|
285 |
break; |
|
286 |
case OR: |
|
287 |
{ |
|
288 |
int LA2_5 = input.LA(3); |
|
289 |
|
|
290 |
if ( (LA2_5==17) ) { |
|
291 |
alt2=1; |
|
292 |
} |
|
293 |
else if ( ((LA2_5>=AND && LA2_5<=PROX)||(LA2_5>=IDENTIFIER && LA2_5<=STRING)||LA2_5==16||LA2_5==19) ) { |
|
294 |
alt2=2; |
|
295 |
} |
|
296 |
else { |
|
297 |
NoViableAltException nvae = |
|
298 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 5, input); |
|
299 |
|
|
300 |
throw nvae; |
|
301 |
} |
|
302 |
} |
|
303 |
break; |
|
304 |
case NOT: |
|
305 |
{ |
|
306 |
int LA2_6 = input.LA(3); |
|
307 |
|
|
308 |
if ( (LA2_6==17) ) { |
|
309 |
alt2=1; |
|
310 |
} |
|
311 |
else if ( ((LA2_6>=AND && LA2_6<=PROX)||(LA2_6>=IDENTIFIER && LA2_6<=STRING)||LA2_6==16||LA2_6==19) ) { |
|
312 |
alt2=2; |
|
313 |
} |
|
314 |
else { |
|
315 |
NoViableAltException nvae = |
|
316 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 6, input); |
|
317 |
|
|
318 |
throw nvae; |
|
319 |
} |
|
320 |
} |
|
321 |
break; |
|
322 |
case PROX: |
|
323 |
{ |
|
324 |
int LA2_7 = input.LA(3); |
|
325 |
|
|
326 |
if ( (LA2_7==17) ) { |
|
327 |
alt2=1; |
|
328 |
} |
|
329 |
else if ( ((LA2_7>=AND && LA2_7<=PROX)||(LA2_7>=IDENTIFIER && LA2_7<=STRING)||LA2_7==16||LA2_7==19) ) { |
|
330 |
alt2=2; |
|
331 |
} |
|
332 |
else { |
|
333 |
NoViableAltException nvae = |
|
334 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 7, input); |
|
335 |
|
|
336 |
throw nvae; |
|
337 |
} |
|
338 |
} |
|
339 |
break; |
|
340 |
default: |
|
341 |
NoViableAltException nvae = |
|
342 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 1, input); |
|
343 |
|
|
344 |
throw nvae; |
|
345 |
} |
|
346 |
|
|
347 |
} |
|
348 |
else { |
|
349 |
NoViableAltException nvae = |
|
350 |
new NoViableAltException("45:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 0, input); |
|
351 |
|
|
352 |
throw nvae; |
|
353 |
} |
|
354 |
switch (alt2) { |
|
355 |
case 1 : |
|
356 |
// Cql.g3:47:11: '>' prefix '=' uri |
|
357 |
{ |
|
358 |
root_0 = (CommonTree)adaptor.nil(); |
|
359 |
|
|
360 |
char_literal2=(Token)input.LT(1); |
|
361 |
match(input,16,FOLLOW_16_in_qscope137); |
|
362 |
char_literal2_tree = (CommonTree)adaptor.create(char_literal2); |
|
363 |
adaptor.addChild(root_0, char_literal2_tree); |
|
364 |
|
|
365 |
pushFollow(FOLLOW_prefix_in_qscope139); |
|
366 |
prefix3=prefix(); |
|
367 |
_fsp--; |
|
368 |
|
|
369 |
adaptor.addChild(root_0, prefix3.getTree()); |
|
370 |
char_literal4=(Token)input.LT(1); |
|
371 |
match(input,17,FOLLOW_17_in_qscope141); |
|
372 |
char_literal4_tree = (CommonTree)adaptor.create(char_literal4); |
|
373 |
adaptor.addChild(root_0, char_literal4_tree); |
|
374 |
|
|
375 |
pushFollow(FOLLOW_uri_in_qscope143); |
|
376 |
uri5=uri(); |
|
377 |
_fsp--; |
|
378 |
|
|
379 |
adaptor.addChild(root_0, uri5.getTree()); |
|
380 |
|
|
381 |
} |
|
382 |
break; |
|
383 |
case 2 : |
|
384 |
// Cql.g3:47:32: '>' uri |
|
385 |
{ |
|
386 |
root_0 = (CommonTree)adaptor.nil(); |
|
387 |
|
|
388 |
char_literal6=(Token)input.LT(1); |
|
389 |
match(input,16,FOLLOW_16_in_qscope147); |
|
390 |
char_literal6_tree = (CommonTree)adaptor.create(char_literal6); |
|
391 |
adaptor.addChild(root_0, char_literal6_tree); |
|
392 |
|
|
393 |
pushFollow(FOLLOW_uri_in_qscope149); |
|
394 |
uri7=uri(); |
|
395 |
_fsp--; |
|
396 |
|
|
397 |
adaptor.addChild(root_0, uri7.getTree()); |
|
398 |
|
|
399 |
} |
|
400 |
break; |
|
401 |
|
|
402 |
} |
|
403 |
retval.stop = input.LT(-1); |
|
404 |
|
|
405 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
406 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
407 |
|
|
408 |
} |
|
409 |
catch (RecognitionException re) { |
|
410 |
reportError(re); |
|
411 |
recover(input,re); |
|
412 |
} |
|
413 |
finally { |
|
414 |
} |
|
415 |
return retval; |
|
416 |
} |
|
417 |
// $ANTLR end qscope |
|
418 |
|
|
419 |
public static class prefix_return extends ParserRuleReturnScope { |
|
420 |
CommonTree tree; |
|
421 |
public Object getTree() { return tree; } |
|
422 |
}; |
|
423 |
|
|
424 |
// $ANTLR start prefix |
|
425 |
// Cql.g3:48:1: prefix : term ; |
|
426 |
public final prefix_return prefix() throws RecognitionException { |
|
427 |
prefix_return retval = new prefix_return(); |
|
428 |
retval.start = input.LT(1); |
|
429 |
|
|
430 |
CommonTree root_0 = null; |
|
431 |
|
|
432 |
term_return term8 = null; |
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
try { |
|
437 |
// Cql.g3:48:9: ( term ) |
|
438 |
// Cql.g3:48:11: term |
|
439 |
{ |
|
440 |
root_0 = (CommonTree)adaptor.nil(); |
|
441 |
|
|
442 |
pushFollow(FOLLOW_term_in_prefix158); |
|
443 |
term8=term(); |
|
444 |
_fsp--; |
|
445 |
|
|
446 |
adaptor.addChild(root_0, term8.getTree()); |
|
447 |
|
|
448 |
} |
|
449 |
|
|
450 |
retval.stop = input.LT(-1); |
|
451 |
|
|
452 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
453 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
454 |
|
|
455 |
} |
|
456 |
catch (RecognitionException re) { |
|
457 |
reportError(re); |
|
458 |
recover(input,re); |
|
459 |
} |
|
460 |
finally { |
|
461 |
} |
|
462 |
return retval; |
|
463 |
} |
|
464 |
// $ANTLR end prefix |
|
465 |
|
|
466 |
public static class uri_return extends ParserRuleReturnScope { |
|
467 |
CommonTree tree; |
|
468 |
public Object getTree() { return tree; } |
|
469 |
}; |
|
470 |
|
|
471 |
// $ANTLR start uri |
|
472 |
// Cql.g3:49:1: uri : term ; |
|
473 |
public final uri_return uri() throws RecognitionException { |
|
474 |
uri_return retval = new uri_return(); |
|
475 |
retval.start = input.LT(1); |
|
476 |
|
|
477 |
CommonTree root_0 = null; |
|
478 |
|
|
479 |
term_return term9 = null; |
|
480 |
|
|
481 |
|
|
482 |
|
|
483 |
try { |
|
484 |
// Cql.g3:49:7: ( term ) |
|
485 |
// Cql.g3:49:9: term |
|
486 |
{ |
|
487 |
root_0 = (CommonTree)adaptor.nil(); |
|
488 |
|
|
489 |
pushFollow(FOLLOW_term_in_uri168); |
|
490 |
term9=term(); |
|
491 |
_fsp--; |
|
492 |
|
|
493 |
adaptor.addChild(root_0, term9.getTree()); |
|
494 |
|
|
495 |
} |
|
496 |
|
|
497 |
retval.stop = input.LT(-1); |
|
498 |
|
|
499 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
500 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
501 |
|
|
502 |
} |
|
503 |
catch (RecognitionException re) { |
|
504 |
reportError(re); |
|
505 |
recover(input,re); |
|
506 |
} |
|
507 |
finally { |
|
508 |
} |
|
509 |
return retval; |
|
510 |
} |
|
511 |
// $ANTLR end uri |
|
512 |
|
|
513 |
public static class scopedClause_return extends ParserRuleReturnScope { |
|
514 |
public CqlClause clause; |
|
515 |
CommonTree tree; |
|
516 |
public Object getTree() { return tree; } |
|
517 |
}; |
|
518 |
|
|
519 |
// $ANTLR start scopedClause |
|
520 |
// Cql.g3:50:1: scopedClause returns [CqlClause clause] : left= searchClause (op= booleanGroup right= searchClause )* ; |
|
521 |
public final scopedClause_return scopedClause() throws RecognitionException { |
|
522 |
scopedClause_return retval = new scopedClause_return(); |
|
523 |
retval.start = input.LT(1); |
|
524 |
|
|
525 |
CommonTree root_0 = null; |
|
526 |
|
|
527 |
searchClause_return left = null; |
|
528 |
|
|
529 |
booleanGroup_return op = null; |
|
530 |
|
|
531 |
searchClause_return right = null; |
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
try { |
|
536 |
// Cql.g3:53:41: (left= searchClause (op= booleanGroup right= searchClause )* ) |
|
537 |
// Cql.g3:54:3: left= searchClause (op= booleanGroup right= searchClause )* |
|
538 |
{ |
|
539 |
root_0 = (CommonTree)adaptor.nil(); |
|
540 |
|
|
541 |
pushFollow(FOLLOW_searchClause_in_scopedClause188); |
|
542 |
left=searchClause(); |
|
543 |
_fsp--; |
|
544 |
|
|
545 |
adaptor.addChild(root_0, left.getTree()); |
|
546 |
retval.clause = left.clause; |
|
547 |
// Cql.g3:55:3: (op= booleanGroup right= searchClause )* |
|
548 |
loop3: |
|
549 |
do { |
|
550 |
int alt3=2; |
|
551 |
int LA3_0 = input.LA(1); |
|
552 |
|
|
553 |
if ( ((LA3_0>=AND && LA3_0<=PROX)) ) { |
|
554 |
alt3=1; |
|
555 |
} |
|
556 |
|
|
557 |
|
|
558 |
switch (alt3) { |
|
559 |
case 1 : |
|
560 |
// Cql.g3:55:4: op= booleanGroup right= searchClause |
|
561 |
{ |
|
562 |
pushFollow(FOLLOW_booleanGroup_in_scopedClause197); |
|
563 |
op=booleanGroup(); |
|
564 |
_fsp--; |
|
565 |
|
|
566 |
root_0 = (CommonTree)adaptor.becomeRoot(op.getTree(), root_0); |
|
567 |
pushFollow(FOLLOW_searchClause_in_scopedClause202); |
|
568 |
right=searchClause(); |
|
569 |
_fsp--; |
|
570 |
|
|
571 |
adaptor.addChild(root_0, right.getTree()); |
|
572 |
retval.clause = new CqlBoolean(retval.clause, op.value, right.clause); |
|
573 |
|
|
574 |
} |
|
575 |
break; |
|
576 |
|
|
577 |
default : |
|
578 |
break loop3; |
|
579 |
} |
|
580 |
} while (true); |
|
581 |
|
|
582 |
|
|
583 |
} |
|
584 |
|
|
585 |
retval.stop = input.LT(-1); |
|
586 |
|
|
587 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
588 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
589 |
|
|
590 |
} |
|
591 |
catch (RecognitionException re) { |
|
592 |
reportError(re); |
|
593 |
recover(input,re); |
|
594 |
} |
|
595 |
finally { |
|
596 |
} |
|
597 |
return retval; |
|
598 |
} |
|
599 |
// $ANTLR end scopedClause |
|
600 |
|
|
601 |
public static class booleanGroup_return extends ParserRuleReturnScope { |
|
602 |
public String value; |
|
603 |
CommonTree tree; |
|
604 |
public Object getTree() { return tree; } |
|
605 |
}; |
|
606 |
|
|
607 |
// $ANTLR start booleanGroup |
|
608 |
// Cql.g3:60:1: booleanGroup returns [String value] : b= bool ( modifierList )? ; |
|
609 |
public final booleanGroup_return booleanGroup() throws RecognitionException { |
|
610 |
booleanGroup_return retval = new booleanGroup_return(); |
|
611 |
retval.start = input.LT(1); |
|
612 |
|
|
613 |
CommonTree root_0 = null; |
|
614 |
|
|
615 |
bool_return b = null; |
|
616 |
|
|
617 |
modifierList_return modifierList10 = null; |
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
try { |
|
622 |
// Cql.g3:60:37: (b= bool ( modifierList )? ) |
|
623 |
// Cql.g3:61:2: b= bool ( modifierList )? |
|
624 |
{ |
|
625 |
root_0 = (CommonTree)adaptor.nil(); |
|
626 |
|
|
627 |
pushFollow(FOLLOW_bool_in_booleanGroup230); |
|
628 |
b=bool(); |
|
629 |
_fsp--; |
|
630 |
|
|
631 |
adaptor.addChild(root_0, b.getTree()); |
|
632 |
// Cql.g3:61:9: ( modifierList )? |
|
633 |
int alt4=2; |
|
634 |
int LA4_0 = input.LA(1); |
|
635 |
|
|
636 |
if ( (LA4_0==18) ) { |
|
637 |
alt4=1; |
|
638 |
} |
|
639 |
switch (alt4) { |
|
640 |
case 1 : |
|
641 |
// Cql.g3:61:10: modifierList |
|
642 |
{ |
|
643 |
pushFollow(FOLLOW_modifierList_in_booleanGroup233); |
|
644 |
modifierList10=modifierList(); |
|
645 |
_fsp--; |
|
646 |
|
|
647 |
adaptor.addChild(root_0, modifierList10.getTree()); |
|
648 |
|
|
649 |
} |
|
650 |
break; |
|
651 |
|
|
652 |
} |
|
653 |
|
|
654 |
retval.value = b.value; |
|
655 |
|
|
656 |
} |
|
657 |
|
|
658 |
retval.stop = input.LT(-1); |
|
659 |
|
|
660 |
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); |
|
661 |
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); |
|
662 |
|
|
663 |
} |
|
664 |
catch (RecognitionException re) { |
|
665 |
reportError(re); |
|
666 |
recover(input,re); |
|
667 |
} |
|
668 |
finally { |
|
669 |
} |
|
670 |
return retval; |
|
671 |
} |
|
672 |
// $ANTLR end booleanGroup |
|
673 |
|
|
674 |
public static class bool_return extends ParserRuleReturnScope { |
|
675 |
public String value; |
|
676 |
CommonTree tree; |
|
677 |
public Object getTree() { return tree; } |
|
678 |
}; |
|
679 |
|
|
680 |
// $ANTLR start bool |
|
681 |
// Cql.g3:62:1: bool returns [String value] : ( AND | OR | NOT | PROX ); |
|
682 |
public final bool_return bool() throws RecognitionException { |
|
683 |
bool_return retval = new bool_return(); |
|
684 |
retval.start = input.LT(1); |
|
685 |
|
|
686 |
CommonTree root_0 = null; |
|
687 |
|
|
688 |
Token AND11=null; |
|
689 |
Token OR12=null; |
|
690 |
Token NOT13=null; |
|
691 |
Token PROX14=null; |
|
692 |
|
|
693 |
CommonTree AND11_tree=null; |
|
694 |
CommonTree OR12_tree=null; |
|
695 |
CommonTree NOT13_tree=null; |
|
696 |
CommonTree PROX14_tree=null; |
Also available in: Unified diff
Deleting project since it was merged with uoa-commons