Project

General

Profile

« Previous | Next » 

Revision 39303

Project scaffolding and basic utility classes

View differences:

modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/Hello.java
1
package eu.dnetlib;
2

  
3

  
4
public class Hello {
5
    public String sayHello(String name){
6
        return "hello "+name;
7
    }
8
}
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/openaire/blacklist/BlacklistManager.java
1
package eu.dnetlib.openaire.blacklist;
2

  
3
import java.io.StringReader;
4

  
5
import javax.xml.ws.wsaddressing.W3CEndpointReference;
6
import javax.xml.xpath.XPath;
7
import javax.xml.xpath.XPathExpressionException;
8
import javax.xml.xpath.XPathFactory;
9

  
10
import org.apache.commons.lang.StringUtils;
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
13
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.beans.factory.annotation.Value;
15
import org.xml.sax.InputSource;
16

  
17
import eu.dnetlib.enabling.database.rmi.DatabaseService;
18
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
19
import eu.dnetlib.enabling.resultset.client.IterableResultSetClient;
20
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
21
import eu.dnetlib.miscutils.collections.MappedCollection;
22
import eu.dnetlib.miscutils.functional.UnaryFunction;
23

  
24
public class BlacklistManager {
25

  
26
	private static final Log log = LogFactory.getLog(BlacklistManager.class); // NOPMD by marko on 11/24/08 5:02 PM
27

  
28
	public enum IIS_STATUS {
29
		UNSOLVED, SOLVED;
30
	}
31

  
32
	public enum STATUS {
33
		PENDING, ACCEPTED, REFUSED, DELETED;
34
	}
35

  
36
	@Value("${dnet.openaire.blacklist.db.name}")
37
	private String blacklistDatabaseName;
38

  
39
	@Autowired
40
	private UniqueServiceLocator serviceLocator;
41
	@Autowired
42
	private ResultSetClientFactory resultSetClientFactory;
43

  
44
	public Iterable<BlacklistEntry> getBlacklist() {
45
		String sqlQuery = "SELECT * from blacklist";
46
		// TODO: ask the database service to get the blacklist entries and translate them into pojo instances.
47
		W3CEndpointReference epr = serviceLocator.getService(DatabaseService.class).searchSQL(blacklistDatabaseName, sqlQuery);
48

  
49
		IterableResultSetClient iter = resultSetClientFactory.getClient(epr);
50

  
51
		return new MappedCollection<BlacklistEntry, String>(iter, new UnaryFunction<BlacklistEntry, String>() {
52

  
53
			@Override
54
			public BlacklistEntry evaluate(final String dbEntry) {
55
				BlacklistEntry be = new BlacklistEntry();
56
				try {
57

  
58
					InputSource doc = new InputSource(new StringReader(dbEntry));
59
					XPath xpath = XPathFactory.newInstance().newXPath();
60
					String provenance = xpath.evaluate("//FIELD[./@name='provenance']", doc);
61
					be.setProvenance(provenance);
62
					if (provenance.equalsIgnoreCase("iis")) {
63
						be.setIisModule(xpath.evaluate("//FIELD[./@name='iis_module']", doc));
64
						be.setIisStatus(IIS_STATUS.valueOf(StringUtils.upperCase(xpath.evaluate("//FIELD[./@name='iis_status']", doc))));
65
					}
66
					// xpath.evaluate("//*[local-name()='objIdentifier']", doc)
67
					be.setCreationDate(xpath.evaluate("//FIELD[./@name='creation_time']", doc));
68
					be.setLastUpdateDate(xpath.evaluate("//FIELD[./@name='last_update_time']", doc));
69
					be.setNote(xpath.evaluate("//FIELD[./@name='note']", doc));
70
					be.setSemanticClass(xpath.evaluate("//FIELD[./@name='semantic_class']", doc));
71
					be.setSemanticScheme(xpath.evaluate("//FIELD[./@name='semantic_scheme']", doc));
72
					be.setStatus(STATUS.valueOf(StringUtils.upperCase(xpath.evaluate("//FIELD[./@name='note']", doc))));
73
					be.setTicketId(xpath.evaluate("//FIELD[./@name='ticket_id']", doc));
74
					be.setUser(xpath.evaluate("//FIELD[./@name='userid']", doc));
75
					be.setSourceObject(xpath.evaluate("//FIELD[./@name='source_object']", doc));
76
					be.setTargetObject(xpath.evaluate("//FIELD[./@name='target_object']", doc));
77
					// TODO: get the array of original identifiers
78
					// xpath.evaluate(("//FIELD[./@name='original_source_objects']/", doc,XPathConstants.NODESET);
79
					// xpath.evaluate(("//FIELD[./@name='target_source_objects']/", doc,XPathConstants.NODESET);
80

  
81
				} catch (XPathExpressionException e) {
82
					log.error("Can't parse blacklist entry from database:\n" + dbEntry);
83
					e.printStackTrace();
84
				}
85
				return be;
86
			}
87
		});
88
	}
89
}
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/openaire/blacklist/BlacklistEntry.java
1
package eu.dnetlib.openaire.blacklist;
2

  
3
import java.util.List;
4

  
5
import com.google.gson.Gson;
6

  
7
import eu.dnetlib.openaire.blacklist.BlacklistManager.IIS_STATUS;
8
import eu.dnetlib.openaire.blacklist.BlacklistManager.STATUS;
9

  
10
public class BlacklistEntry {
11

  
12
	/** The user who reported the wrong link **/
13
	private String user;
14
	/** A note regarding the reported 'wrong' relationship **/
15
	private String note;
16
	/** The id of the ticket associated to this entry **/
17
	private String ticketId;
18
	/** Provenance of the relationship. 'iis' when the relatonship is inferred **/
19
	private String provenance;
20
	/** Semantics of the relationship. E.g. 'isProducedBy' and 'dnet:result_project_relations' **/
21
	private String semanticClass, semanticScheme;
22
	/** The inference module that generated the relationship. Blank if provenance is not 'iis'. **/
23
	private String iisModule;
24

  
25
	/** Status of the report **/
26
	private STATUS status;
27
	/** Status of the issue from the pov of IIS. Blank if provenance is not 'iis'. **/
28
	private IIS_STATUS iisStatus;
29

  
30
	// using String instead of date because the datasource manager forgets the types.
31
	private String creationDate, lastUpdateDate;
32

  
33
	/** OpenAIRE ids of the objects linked by the 'wrong' relationship **/
34
	private String sourceObject, targetObject;
35
	/** If the source or the target are representatives, then the following lists are not empty and contain the ids of the merged objects **/
36
	private List<String> originalSourceObjects, originalTargetObjects;
37

  
38
	@Override
39
	public String toString() {
40
		Gson gson = new Gson();
41
		return gson.toJson(this);
42
	}
43

  
44
	public String getUser() {
45
		return user;
46
	}
47

  
48
	public void setUser(final String user) {
49
		this.user = user;
50
	}
51

  
52
	public String getNote() {
53
		return note;
54
	}
55

  
56
	public void setNote(final String note) {
57
		this.note = note;
58
	}
59

  
60
	public String getTicketId() {
61
		return ticketId;
62
	}
63

  
64
	public void setTicketId(final String ticketId) {
65
		this.ticketId = ticketId;
66
	}
67

  
68
	public String getProvenance() {
69
		return provenance;
70
	}
71

  
72
	public void setProvenance(final String provenance) {
73
		this.provenance = provenance;
74
	}
75

  
76
	public String getSemanticClass() {
77
		return semanticClass;
78
	}
79

  
80
	public void setSemanticClass(final String semanticClass) {
81
		this.semanticClass = semanticClass;
82
	}
83

  
84
	public String getSemanticScheme() {
85
		return semanticScheme;
86
	}
87

  
88
	public void setSemanticScheme(final String semanticScheme) {
89
		this.semanticScheme = semanticScheme;
90
	}
91

  
92
	public String getIisModule() {
93
		return iisModule;
94
	}
95

  
96
	public void setIisModule(final String iisModule) {
97
		this.iisModule = iisModule;
98
	}
99

  
100
	public STATUS getStatus() {
101
		return status;
102
	}
103

  
104
	public void setStatus(final STATUS status) {
105
		this.status = status;
106
	}
107

  
108
	public IIS_STATUS getIisStatus() {
109
		return iisStatus;
110
	}
111

  
112
	public void setIisStatus(final IIS_STATUS iisStatus) {
113
		this.iisStatus = iisStatus;
114
	}
115

  
116
	public String getCreationDate() {
117
		return creationDate;
118
	}
119

  
120
	public void setCreationDate(final String creationDate) {
121
		this.creationDate = creationDate;
122
	}
123

  
124
	public String getLastUpdateDate() {
125
		return lastUpdateDate;
126
	}
127

  
128
	public void setLastUpdateDate(final String lastUpdateDate) {
129
		this.lastUpdateDate = lastUpdateDate;
130
	}
131

  
132
	public String getSourceObject() {
133
		return sourceObject;
134
	}
135

  
136
	public void setSourceObject(final String sourceObject) {
137
		this.sourceObject = sourceObject;
138
	}
139

  
140
	public String getTargetObject() {
141
		return targetObject;
142
	}
143

  
144
	public void setTargetObject(final String targetObject) {
145
		this.targetObject = targetObject;
146
	}
147

  
148
	public List<String> getOriginalSourceObjects() {
149
		return originalSourceObjects;
150
	}
151

  
152
	public void setOriginalSourceObjects(final List<String> originalSourceObjects) {
153
		this.originalSourceObjects = originalSourceObjects;
154
	}
155

  
156
	public List<String> getOriginalTargetObjects() {
157
		return originalTargetObjects;
158
	}
159

  
160
	public void setOriginalTargetObjects(final List<String> originalTargetObjects) {
161
		this.originalTargetObjects = originalTargetObjects;
162
	}
163

  
164
}
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/functioanlity/modular/ui/blacklist/BlacklistEntryPointController.java
1
package eu.dnetlib.functioanlity.modular.ui.blacklist;
2

  
3
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
4
import org.springframework.ui.ModelMap;
5

  
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletResponse;
8

  
9
/**
10
 * Created by alessia on 18/09/15.
11
 */
12
public class BlacklistEntryPointController extends ModuleEntryPoint {
13

  
14
		@Override
15
		protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {}
16

  
17
}
modules/dnet-openaire-blacklist/trunk/src/main/java/eu/dnetlib/functioanlity/modular/ui/blacklist/BlacklistInternalController.java
1
package eu.dnetlib.functioanlity.modular.ui.blacklist;
2

  
3
import org.springframework.stereotype.Controller;
4
import org.springframework.web.bind.annotation.RequestMapping;
5

  
6
import javax.servlet.http.HttpServletResponse;
7

  
8
/**
9
 * Created by alessia on 18/09/15.
10
 */
11
@Controller
12
public class BlacklistInternalController {
13

  
14
	@RequestMapping(value = "/ui/getBlacklist.do")
15
	public void getBlacklist(final HttpServletResponse response) throws Exception {
16

  
17
	}
18
}
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/applicationContext-dnet-openaire-blacklist.properties
1
dnet.openaire.blacklist.db.name=dnet_openaire_blacklist
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-blacklist.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
4
	   xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
5
	   xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
6
	   xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
7
	   xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
8
	   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
9
						http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
10
						http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
11
						http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
12
						http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
13
						http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
14
						http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
15
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
16

  
17

  
18
	<bean name="/ui/blacklist.do"
19
		  class="eu.dnetlib.functionality.modular.ui.blacklist.BlacklistEntryPointController"
20
		  p:menu="Blacklist Manager"
21
		  p:title="Blacklist Manager"
22
		  p:description="Manager for the Blacklist of links"
23
		  p:group="Tools">
24
		<property name="permissionLevels">
25
			<set>
26
				<value>IS_ADMIN</value>
27
			</set>
28
		</property>
29
	</bean>
30

  
31
</beans>
modules/dnet-openaire-blacklist/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/blacklistInspector.st
1
$common/master( header={
2
	<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
3
	<script type="text/javascript" src="../resources/js/angular-route.min.js"></script>
4
	<script type="text/javascript" src="../resources/js/db_manager.js"></script>
5
	<script type="text/javascript" src="../resources/js/db_manager_controllers.js"></script>
6
}, body={
7
	<div ng-app="dbManager">
8
		<div ng-view></div>
9
	</div>
10
} )$
modules/dnet-openaire-blacklist/trunk/pom.xml
13 13
	<packaging>jar</packaging>
14 14
	<version>0.0.1-SNAPSHOT</version>
15 15
	<dependencies>
16
		<dependency>
17
			<groupId>eu.dnetlib</groupId>
18
			<artifactId>cnr-resultset-client</artifactId>
19
			<version>[2.0.0,3.0.0)</version>
20
		</dependency>
21
		<dependency>
22
			<groupId>eu.dnetlib</groupId>
23
			<artifactId>cnr-enabling-database-api</artifactId>
24
			<version>[1.0.0,2.0.0)</version>
25
		</dependency>
26
		<dependency>
27
			<groupId>eu.dnetlib</groupId>
28
			<artifactId>dnet-modular-ui</artifactId>
29
			<version>[3.0.0,4.0.0)</version>
30
		</dependency>
31
		<dependency>
32
			<groupId>javax.servlet</groupId>
33
			<artifactId>javax.servlet-api</artifactId>
34
			<version>${javax.servlet.version}</version>
35
			<scope>provided</scope>
36
		</dependency>
37

  
16 38
	</dependencies>
17 39
</project>

Also available in: Unified diff