Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/pom.xml
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/pom.xml	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/pom.xml	(revision 48079)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet45-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-modular-cleaning-rules-ui</artifactId>
+	<packaging>jar</packaging>
+	<version>2.0.1</version>
+	<scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-ui</artifactId>
+			<version>[3.0.0,4.0.0)</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+</project>
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/deploy.info
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/deploy.info	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/deploy.info	(revision 48079)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-cleaning-rules-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-cleaning-rules-ui"}
\ No newline at end of file
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/CleaningRuleController.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/CleaningRuleController.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/CleaningRuleController.java	(revision 48079)
@@ -0,0 +1,138 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.controllers;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.bind.JAXBException;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.adapters.CleanerAdapter;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.adapters.RuleAdapter;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.model.Cleaner;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.model.Rule;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+@Controller
+public class CleaningRuleController {
+
+	private final Log log = LogFactory.getLog(CleaningRuleController.class);
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	@RequestMapping("/ui/cleaners.json")
+	public void getCleaners(final HttpServletResponse response) throws ISLookUpException, IOException {
+		log.info("cleaners.json");
+		String query = "for $x in collection('/db/DRIVER/CleanerDSResources/CleanerDSResourceType') order by $x//CLEANER_NAME "
+				+ "return concat ($x//RESOURCE_IDENTIFIER/@value,' §§§ ',$x//CLEANER_NAME,' §§§ ',$x//CLEANER_DESCRIPTION)";
+
+		List<Cleaner> cleaners = Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query), new CleanerAdapter());
+		IOUtils.copy(new StringReader(new Gson().toJson(cleaners)), response.getOutputStream());
+	}
+
+	@RequestMapping("/ui/rules.json")
+	public void getRules(final HttpServletResponse response, @RequestParam(value = "cleanerId", required = true) final String cleanerId)
+			throws ISLookUpException, IOException {
+		log.info("rules.json?cleanerId=" + cleanerId);
+
+		String query = "for $x in /*[.//RESOURCE_IDENTIFIER/@value=\"{cleanerId}\"]//RULE order by $x/@xpath "
+				+ "return concat ($x/@xpath,' §§§ ',$x/@vocabularies,' §§§ ',$x/@strict)";
+		query = query.replace("{cleanerId}", cleanerId);
+
+		List<Rule> rules = Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query), new RuleAdapter());
+		IOUtils.copy(new StringReader(new Gson().toJson(rules)), response.getOutputStream());
+	}
+
+	@RequestMapping(value = "/ui/createCleaner", method = RequestMethod.POST)
+	public void createCleaner(final HttpServletResponse response, final HttpServletRequest request) throws IOException, ISRegistryException, JAXBException {
+		log.info("create vocabulary");
+
+		Cleaner cleaner = new Gson().fromJson(request.getReader(), Cleaner.class);
+
+		StringTemplate st = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/cleaner.xml.st")));
+		st.setAttribute("name", cleaner.getName());
+		st.setAttribute("description", cleaner.getDescription());
+		st.setAttribute("date", DateUtils.now_ISO8601());
+		String newVocabularyId = serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString());
+
+		IOUtils.copy(new StringReader(newVocabularyId), response.getOutputStream());
+	}
+
+	@RequestMapping(value = "/ui/commitCleanerInfo", method = RequestMethod.POST)
+	public void commitCleanerInfo(final HttpServletResponse response,
+			final HttpServletRequest request,
+			@RequestParam(value = "cleanerId", required = true) final String cleanerId) throws IOException, ISRegistryException, JAXBException {
+		log.info("committing cleaner info id = " + cleanerId);
+
+		Cleaner cleaner = new Gson().fromJson(request.getReader(), Cleaner.class);
+
+		String xml = "<CLEANER_NAME>{name}</CLEANER_NAME>";
+		xml = xml.replace("{name}", StringEscapeUtils.escapeXml(cleaner.getName()));
+		serviceLocator.getService(ISRegistryService.class).updateProfileNode(cleanerId, "//CLEANER_NAME", xml);
+
+		xml = "<CLEANER_DESCRIPTION>{desc}</CLEANER_DESCRIPTION>";
+		xml = xml.replace("{desc}", StringEscapeUtils.escapeXml(cleaner.getDescription()));
+		serviceLocator.getService(ISRegistryService.class).updateProfileNode(cleanerId, "//CLEANER_DESCRIPTION", xml);
+
+		IOUtils.copy(new StringReader("Vocabulary info saved correctly!"), response.getOutputStream());
+	}
+
+	@RequestMapping(value = "/ui/commitCleaner", method = RequestMethod.POST)
+	public void commitRules(final HttpServletResponse response,
+			final HttpServletRequest request,
+			@RequestParam(value = "cleanerId", required = true) final String cleanerId) throws IOException, JAXBException, ISRegistryException {
+		log.info("committing rules for cleaner id=" + cleanerId);
+
+		Type collectionType = new TypeToken<ArrayList<Rule>>() {}.getType();
+		ArrayList<Rule> rules = new Gson().fromJson(request.getReader(), collectionType);
+
+		// prepare terms for XML
+		for (Rule r : rules) {
+			r.setXpath(StringEscapeUtils.escapeXml(r.getXpath()));
+			List<String> vocabulariesXmlAdapted = new ArrayList<String>();
+			for (String v : r.getAppliedVocabularies()) {
+				vocabulariesXmlAdapted.add(StringEscapeUtils.escapeXml(v));
+			}
+			r.setAppliedVocabularies(vocabulariesXmlAdapted);
+		}
+
+		StringTemplate st = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/rules.xml.st")));
+		st.setAttribute("rules", rules);
+		serviceLocator.getService(ISRegistryService.class).updateProfileNode(cleanerId, "//CLEANER_RULES", st.toString());
+
+		IOUtils.copy(new StringReader("Cleaner saved correctly!"), response.getOutputStream());
+	}
+
+	@RequestMapping(value = "/ui/dropCleaner", method = RequestMethod.GET)
+	public void dropCleaner(final HttpServletResponse response,
+			final HttpServletRequest request,
+			@RequestParam(value = "cleanerId", required = true) final String cleanerId) throws IOException, ISRegistryException, JAXBException {
+		log.info("delete cleaner id=" + cleanerId);
+
+		serviceLocator.getService(ISRegistryService.class).deleteProfile(cleanerId);
+	}
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/EntryPointController.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/EntryPointController.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/controllers/EntryPointController.java	(revision 48079)
@@ -0,0 +1,17 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.controllers;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.ui.ModelMap;
+
+import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
+
+public class EntryPointController extends ModuleEntryPoint {
+
+	@Override
+	protected void initialize(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception {
+		
+	}
+
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Rule.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Rule.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Rule.java	(revision 48079)
@@ -0,0 +1,44 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.model;
+
+import java.util.List;
+
+public class Rule {
+	private String xpath;
+	private List<String> appliedVocabularies;
+	private boolean strict;
+
+	public Rule() {
+	}
+
+	public Rule(String xpath, List<String> appliedVocabularies, boolean strict) {
+		super();
+		this.xpath = xpath;
+		this.appliedVocabularies = appliedVocabularies;
+		this.strict = strict;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(String xpath) {
+		this.xpath = xpath;
+	}
+
+	public List<String> getAppliedVocabularies() {
+		return appliedVocabularies;
+	}
+
+	public void setAppliedVocabularies(List<String> appliedVocabularies) {
+		this.appliedVocabularies = appliedVocabularies;
+	}
+
+	public boolean isStrict() {
+		return strict;
+	}
+
+	public void setStrict(boolean strict) {
+		this.strict = strict;
+	}
+
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Cleaner.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Cleaner.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/model/Cleaner.java	(revision 48079)
@@ -0,0 +1,52 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.model;
+
+public class Cleaner {
+	private String id;
+	private String idHtml;
+	private String name;
+	private String description;
+
+	public Cleaner() {
+	}
+
+	public Cleaner(String id, String idHtml, String name, String description) {
+		super();
+		this.id = id;
+		this.idHtml = idHtml;
+		this.name = name;
+		this.description = description;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getIdHtml() {
+		return idHtml;
+	}
+
+	public void setIdHtml(String idHtml) {
+		this.idHtml = idHtml;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/RuleAdapter.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/RuleAdapter.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/RuleAdapter.java	(revision 48079)
@@ -0,0 +1,31 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.adapters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.functionality.modular.ui.cleaningrules.controllers.CleaningRuleController;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.model.Rule;
+
+/**
+ * This class is used in {@link CleaningRuleController} when un-marshaling of a {@link Rule} object is needed.
+ * 
+ * @author Andrea Mannocci
+ */
+public class RuleAdapter implements Function<String, Rule> {
+
+	@Override
+	public Rule apply(final String s) {
+		String[] tokens = s.split("§§§");
+		return new Rule(tokens[0].trim(), // xpath
+				parseVocabularyList(tokens[1].trim()), // vocabularies
+				Boolean.valueOf(tokens[2].trim()));// strict
+	}
+
+	List<String> parseVocabularyList(final String s) {
+		return new ArrayList<String>(Arrays.asList(s.split(", ")));
+	}
+
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/CleanerAdapter.java
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/CleanerAdapter.java	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/cleaningrules/adapters/CleanerAdapter.java	(revision 48079)
@@ -0,0 +1,23 @@
+package eu.dnetlib.functionality.modular.ui.cleaningrules.adapters;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.functionality.modular.ui.cleaningrules.controllers.CleaningRuleController;
+import eu.dnetlib.functionality.modular.ui.cleaningrules.model.Cleaner;
+
+/**
+ * This class is used in {@link CleaningRuleController} when un-marshaling of
+ * a {@link Cleaner} object is needed.
+ * @author Andrea Mannocci
+ */
+public class CleanerAdapter implements Function<String, Cleaner> {
+
+	public Cleaner apply(String s) {
+		String[] tokens = s.split("§§§");
+		return new Cleaner(		tokens[0].trim(), 
+								tokens[0].trim().replaceAll("\\W", ""), 
+								tokens[1].trim(), 
+								tokens[2].trim());
+	}
+
+}
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-cleaning-rules.xml
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-cleaning-rules.xml	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-cleaning-rules.xml	(revision 48079)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+	<bean name="/ui/cleaningRules.do"
+		class="eu.dnetlib.functionality.modular.ui.cleaningrules.controllers.EntryPointController"
+		p:menu="Cleaning rules editor" 
+		p:title="D-NET cleaning rules editor"
+		p:description="D-NET cleaning rules editor" 
+		p:group="Configuration">
+		<property name="permissionLevels">
+			<set>
+				<value>USER</value>
+			</set>
+		</property>
+	</bean>
+
+</beans>
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/cleaningRules.st
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/cleaningRules.st	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/cleaningRules.st	(revision 48079)
@@ -0,0 +1,154 @@
+$common/master( header={
+	<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
+	<script type="text/javascript" src="../resources/js/cleaningRules.js" ></script>
+}, body={
+	<div ng-app="cleaningRulesUI" ng-controller="cleaningRulesCtrl">
+		<div class="row">
+			<div class="column col-xs-12 col-sm-12 col-md-3 col-lg-3">
+				<form role="form" class="form-inline">
+					<button type="button" class="btn btn-default" ng-click="selectedCleanerIndex = null; showInfoModal()">
+						New cleaner <span class="glyphicon glyphicon-plus"></span>
+					</button>
+					<div class="form-group pull-right">
+						<input type="text" class="form-control" ng-model="cleanerFilter" placeholder="Filter by...">
+					</div>
+				</form>
+				<br/><br/>
+				<ul class="nav nav-pills nav-stacked">
+					<li ng-repeat="cleaner in cleaners | filter:cleanerFilter"
+						ng-class="{'active': (selectedCleanerIndex != null) && (cleaner.id == cleaners[selectedCleanerIndex].id)}"
+						ng-click="loadRules(cleaner)">
+							<a>{{cleaner.name}}<span class="glyphicon glyphicon-chevron-right pull-right"/></a>
+					</li>
+				</ul>
+			</div>
+			<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9" ng-show="rules != null && selectedCleanerIndex != null">
+				<form role="form" class="form-inline">
+					<div class="btn-group">
+						<button type="button" class="btn btn-default" ng-click="showInfoModal()">
+							Edit info <span class="glyphicon glyphicon-book"></span>
+						</button>
+						<button type="button" class="btn btn-default" ng-click="showRuleModal(null)">
+							New rule <span class="glyphicon glyphicon-pencil"></span>
+						</button>
+						<button type="button" class="btn btn-default" ng-click="commit()">
+							Commit <span class="glyphicon glyphicon-floppy-saved"></span>
+						</button>
+						<button type="button" class="btn btn-default" ng-click="reloadRules()">
+							Discard all <span class="glyphicon glyphicon-repeat"></span>
+						</button>
+						<button type="button" class="btn btn-default" ng-click="dropCleaner()">
+							Drop cleaner <span class="glyphicon glyphicon-trash"></span>
+						</button>
+					</div>
+					<div class="form-group pull-right">
+						<input type="text" class="form-control" ng-model="ruleFilter" placeholder="Filter by...">
+					</div>
+				</form>
+				<br><br>
+	            <table class="table table-bordered">
+	            	<thead>
+	            	    <tr>
+	            	     	<th>XPath</th>
+	            	      	<th>Applied vocabularies</th>
+	            	      	<th>Strict</th>
+	            	      	<th>Actions</th>
+	            	    </tr>
+            	  	</thead>
+            	  	<tbody>
+	        	  		<tr ng-repeat="rule in rules | filter:ruleFilter">
+					      	<td class="col-xs-7">{{rule.xpath}}</td>
+					      	<td class="col-xs-3">
+						      	<ul>
+						      		<li ng-repeat="vocabulary in rule.appliedVocabularies">{{vocabulary}} <span ng-show="!isValid(vocabulary)" class="label label-important">Missing!!</span></li>
+						      	</ul>
+					      	</td>
+					      	<td class="col-xs-1">
+					      		<span class="glyphicon" ng-class="{'glyphicon-ok': rule.strict, 'glyphicon-remove': !rule.strict}"></span>
+					      	</td>
+					      	<td class="col-xs-1">
+					      		<button type="button" class="btn btn-xs btn-primary"  ng-click="showRuleModal(rule)">
+					      			<span class="glyphicon glyphicon-pencil"></span>
+				      			</button>
+					      		<button type="button" class="btn btn-xs btn-danger" ng-click="deleteRule(rule)">
+					      			<span class="glyphicon glyphicon-trash"></span>
+				      			</button>
+				      		</td>
+					    </tr>
+            	  	</tbody>
+				</table>
+			</div>
+		</div>
+			
+		<!-- infoModal -->
+		<div id="infoModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="infoModalLabel" aria-hidden="true">
+			<div class="modal-dialog">
+				<div class="modal-content">
+					<div class="modal-header">
+						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+						<h4 id="infoModalLabel">Cleaner information</h4>
+					</div>
+					<div class="modal-body">
+						<form name="infoForm" class="form-horizontal" role="form">
+							<div class="form-group" ng-class="{'has-warning': !modalInfo.name}">
+								<label class="col-sm-4 control-label" for="cleanerName">Cleaner name</label>
+							    <div class="col-sm-8">
+							      	<input class="form-control" ng-disabled="selectedCleanerIndex != null" type="text" name="cleanerName" placeholder="cleaner name" ng-model="modalInfo.name">
+							    </div>
+							</div>
+							<div class="form-group">
+								<label class="col-sm-4 control-label" for="cleanerDescription">Cleaner description</label>
+								<div class="col-sm-8">
+									<input class="form-control" ng-disabled="selectedCleanerIndex != null" type="text" name="cleanerDescription" placeholder="cleaner description" ng-model="modalInfo.description">
+								</div>
+							</div>
+						</form>
+					</div>
+					<div class="modal-footer">
+						<button class="btn btn-primary" ng-disabled="!modalInfo.name" ng-click="editInfo()">Save</button>
+					</div>
+				</div>
+			</div>
+		</div> <!-- info modal -->
+			
+		<!-- Le rule modal -->
+		<div id="ruleModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="ruleModalLabel" aria-hidden="true">
+			<div class="modal-dialog  modal-lg">
+				<div class="modal-content">
+					<div class="modal-header">
+						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+						<h4 id="ruleModalLabel">Rule editor</h4>
+					</div>
+					<div class="modal-body">
+						<form name="infoForm" class="form-horizontal" role="form">
+							<div class="form-group" ng-class="{'has-warning': !modalRule.xpath}">
+								<label class="col-sm-4 control-label">XPath</label>
+								<div class="col-sm-8">
+									<textarea rows="3" class="col-xs-12" type="text" placeholder="xpath" ng-model="modalRule.xpath"></textarea> 
+								</div>
+							</div>
+							<div class="form-group">
+								<label class="col-sm-4 control-label">Strict</label>
+								<div class="col-sm-8">
+									<label class="radio"><input type="radio" ng-model="modalRule.strict" ng-value="true"> True</label>
+									<label class="radio"><input type="radio" ng-model="modalRule.strict" ng-value="false" checked> False</label>
+								</div>
+							</div>
+							<div class="form-group">
+								<label class="col-sm-4 control-label">Vocabularies applied</label>
+								<div class="col-sm-8">
+									<input type="text" class="form-control" ng-model="vocabularyFilter" placeholder="Filter by...">
+									<label class="checkbox" ng-repeat="vocabulary in modalRule.vocabularies | filter:vocabularyFilter"><input type="checkbox" ng-model="vocabulary.checked"> {{vocabulary.name}}</label>
+								</div>
+							</div>
+						</form>
+					</div>
+					<div class="modal-footer">
+						<button type="button" class="btn btn-primary" ng-disabled="!modalRule.xpath" ng-click="editRule()">Save</button>
+					</div>
+				</div>
+			</div>
+		</div> <!-- rule modal -->
+			
+	</div>
+} )$
\ No newline at end of file
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/cleaner.xml.st
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/cleaner.xml.st	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/cleaner.xml.st	(revision 48079)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="CleanerDSResourceType" />
+		<RESOURCE_KIND value="CleanerDSResources" />
+		<RESOURCE_URI value="" />
+		<DATE_OF_CREATION value="$date$" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<CLEANER_NAME>$name$</CLEANER_NAME>
+			<CLEANER_DESCRIPTION>$description$</CLEANER_DESCRIPTION>
+			<CLEANER_RULES>
+				<RULE xpath="//whatever" vocabularies="" strict="true" />
+			</CLEANER_RULES>
+		</CONFIGURATION>
+		<STATUS>
+			<LAST_UPDATE value="$date$" />
+		</STATUS>
+		<SECURITY_PARAMETERS>String</SECURITY_PARAMETERS>
+	</BODY>
+</RESOURCE_PROFILE>
\ No newline at end of file
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/rules.xml.st
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/rules.xml.st	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/functionality/modular/templates/rules.xml.st	(revision 48079)
@@ -0,0 +1,5 @@
+<CLEANER_RULES>
+	$rules:{r|
+	<RULE vocabularies='$r.appliedVocabularies:{v|$v$};separator=", "$' xpath="$r.xpath$" strict="$r.strict$" />
+	}$
+</CLEANER_RULES>
\ No newline at end of file
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/web/resources/js/cleaningRules.js
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/web/resources/js/cleaningRules.js	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1/src/main/resources/eu/dnetlib/web/resources/js/cleaningRules.js	(revision 48079)
@@ -0,0 +1,240 @@
+var module = angular.module('cleaningRulesUI', []);
+
+module.directive('tooltip', function() {
+    return {
+    	restrict: 'A',
+    	link: function(scope, element, attrs)
+        {
+            $(element).tooltip();
+        }
+    }
+});
+
+function cleaningRulesCtrl($scope, $http) {
+	$scope.rules = [];
+	$scope.modalInfo = {};
+	$scope.modalCleaner = {};
+	$scope.modalRule = {};
+
+	initSpinner();
+	showSpinner();
+	
+	$scope.startup = function() {
+		$http.get('cleaners.json')
+		.success(
+			function(data) {
+	    		$scope.cleaners = data;
+	    		// load vocabularies
+			    $http.get('vocabularies.json')
+				.success(
+					function(data) {
+			    		$scope.modalRule.vocabularies = data;
+			    		hideSpinner();
+			 		})
+				.error(
+			        function() {
+			        	show_notification("error",'An error occurred while fetching available vocabularies..');
+			        	hideSpinner();
+			        }
+			    );
+	 		})
+		.error(
+	        function() {
+	        	show_notification("error",'An error occurred while fetching registered Cleaner Service Profiles');
+	        	hideSpinner();
+	        }
+	    );
+	}
+	
+	$scope.startup();
+
+    $scope.loadRules = function(cleaner) {
+    	showSpinner();
+		$http.get('rules.json?cleanerId=' + cleaner.id)
+        .success(
+            function(data) {
+                $scope.selectedCleanerIndex = $scope.cleaners.indexOf(cleaner);
+                $scope.rules = data;
+                hidePermanotice();
+                hideSpinner();
+            }
+        ).error(
+            function() {
+            	show_notification("error",'An error occurred while fetching cleaning rules for cleaner ' + cleaner.name);
+            	hideSpinner();
+            }
+        );	
+    }
+
+    $scope.reloadRules = function() {
+        $scope.loadRules($scope.cleaners[$scope.selectedCleanerIndex]);
+    }
+    
+    /*---------ADD/EDIT---------*/
+	$scope.showInfoModal = function() {
+		if ($scope.selectedCleanerIndex != null) {
+			// show modal for editing info of existing vocabulary
+			$scope.modalInfo.name = $scope.cleaners[$scope.selectedCleanerIndex].name;
+			$scope.modalInfo.description = $scope.cleaners[$scope.selectedCleanerIndex].description;
+		} else {
+			// show modal for new vocabulary
+			$scope.modalInfo.name = '';
+			$scope.modalInfo.description = '';
+			hidePermanotice();
+		}
+		$('#infoModal').modal();
+	}
+
+    $scope.showRuleModal = function(rule) {
+    	$scope.selectedRuleIndex = $scope.rules.indexOf(rule);
+		if(rule != null) {
+			$scope.modalRule.xpath = rule.xpath;
+			$scope.modalRule.strict = rule.strict;
+			$scope.tickAppliedVocabularies(rule.appliedVocabularies);
+		} else {
+			// reset modal variables
+			$scope.modalRule.xpath = '';
+			$scope.modalRule.strict = '';
+			$scope.tickAppliedVocabularies(null);
+		}
+		$('#ruleModal').modal();
+    }
+    
+	$scope.editInfo = function() {
+		showSpinner();
+		if ($scope.selectedCleanerIndex == null) {
+			// new cleaner
+			$http.post('createCleaner', {"name" : $scope.modalInfo.name, "description" : $scope.modalInfo.description})
+				.success(
+					function(data) {
+						show_notification("success", "Cleaner created successfully!");
+						$scope.cleaners.push({
+							"id" : data,
+							"name" : $scope.modalInfo.name,
+							"description" : $scope.modalInfo.description});
+						$scope.startup();
+						hideSpinner();
+					})
+				.error(
+					function() {
+						show_notification("error", "An error occurred while creating the cleaner profile");
+						hideSpinner();
+					});
+		} else {
+			// edit existing cleaner info
+			$http.post('commitCleanerInfo?cleanerId=' + $scope.cleaners[$scope.selectedCleanerIndex].id, {
+						"name" : $scope.modalInfo.name, 
+						"description" : $scope.modalInfo.description})
+				.success(
+					function(data) {
+						// update model
+						$scope.cleaners[$scope.selectedCleanerIndex].name = $scope.modalInfo.name;
+						$scope.cleaners[$scope.selectedCleanerIndex].description = $scope.modalInfo.description;
+						show_notification("success", data);
+						$scope.startup();
+						hideSpinner();
+					})
+				.error(
+					function() {
+						show_notification("error", "Cannot edit info..");
+						hideSpinner();
+					});
+		}
+		// dismiss modal
+		$('.modal').modal('hide');
+	}
+
+	$scope.editRule = function() {
+		var appliedVocabularies = [];
+		for (var i in $scope.modalRule.vocabularies) {
+			if ($scope.modalRule.vocabularies[i].checked)
+				appliedVocabularies.push($scope.modalRule.vocabularies[i].name);
+		}
+
+		if ($scope.selectedRuleIndex == -1) {
+			// new rule being added
+			$scope.rules.push({"xpath":$scope.modalRule.xpath,"strict":$scope.modalRule.strict,"appliedVocabularies":appliedVocabularies});
+		} else {
+			// existing rule being updated
+			$scope.rules[$scope.selectedRuleIndex].xpath = $scope.modalRule.xpath;
+			$scope.rules[$scope.selectedRuleIndex].strict = $scope.modalRule.strict;
+			$scope.rules[$scope.selectedRuleIndex].appliedVocabularies = appliedVocabularies;
+		}
+		// dismiss modal
+		$('.modal').modal('hide');
+		showPermanotice("Uncommitted changes!");
+    }
+	
+	/*---------DELETE---------*/
+	$scope.dropCleaner = function() {
+		showSpinner();
+		$http.get('dropCleaner?cleanerId=' + $scope.cleaners[$scope.selectedCleanerIndex].id)
+			.success(
+				function() {
+					$scope.cleaners.splice($scope.selectedCleanerIndex, 1);
+					$scope.selectedCleanerIndex = null;
+					show_notification('success', "Vocabulary deleted successfully!");
+					hideSpinner();
+				})
+			.error(
+				function() {
+					hideSpinner();
+					show_notification('error', "Cannot drop cleaner "+$scope.cleaners[$scope.selectedCleanerIndex].name);
+				});
+	}
+
+    $scope.deleteRule = function(rule) {
+    	var ruleIndex = $scope.rules.indexOf(rule);
+    	$scope.rules.splice(ruleIndex,1);
+    	showPermanotice("Uncommitted changes!");
+    }
+    
+    /*-----------UTILITY----------*/
+    $scope.tickAppliedVocabularies = function(appliedVocabularies) {
+    	if (appliedVocabularies == null) {
+    		// i.e. new rule
+    		for (var i in $scope.modalRule.vocabularies){
+    			$scope.modalRule.vocabularies[i].checked = false;
+    		}
+    	} else {
+    		// i.e. existing rule
+    		for (var i in $scope.modalRule.vocabularies){
+    			for (var j in appliedVocabularies) {
+    				if ($scope.modalRule.vocabularies[i].name == appliedVocabularies[j]) {
+    					$scope.modalRule.vocabularies[i].checked = true;
+    					break;
+    				} else {
+    					$scope.modalRule.vocabularies[i].checked = false;
+    				}
+    			}
+    		}
+    	}
+    }
+
+	/*---------COMMIT---------*/
+    $scope.commit = function() {
+    	showSpinner();
+    	$http.post('commitCleaner?cleanerId='+$scope.cleaners[$scope.selectedCleanerIndex].id, $scope.rules)
+    	.success(function(data){
+    		hidePermanotice();
+    		$scope.reloadRules();
+    		show_notification("success", data);
+    		hideSpinner();
+    	})
+    	.error(function(){
+    		show_notification("error",'An error occurred while saving modifications for cleaner '+$scope.cleaners[$scope.selectedCleanerIndex].name);
+    		showPermanotice("Uncommitted changes!");
+    		hideSpinner();
+    	});
+    }
+    
+    /*---------UTILITY---------*/
+    $scope.isValid = function(vocabularyName) {
+    	var ret =  false;
+    	for (var i in $scope.modalRule.vocabularies) {
+			if ($scope.modalRule.vocabularies[i].name == vocabularyName)
+				ret = true;
+		}
+    	return ret;
+    }
+}
\ No newline at end of file
Index: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1
===================================================================
--- modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1	(nonexistent)
+++ modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1	(revision 48079)

Property changes on: modules/dnet-modular-cleaning-rules-ui/tags/dnet-modular-cleaning-rules-ui-2.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,4 ##
+.settings
+.project
+.classpath
+target
