stable version for metadata (model 1.2.8)

git-svn-id: svn://svn.forge.objectweb.org/svnroot/weblab/tags/WebLabServices/Portlets/metadata-portlet/v2.2.1@4344 a803c184-d8de-4a0e-a52b-d3eef88212b6
parent d43db8e1
This diff is collapsed.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.ow2.weblab.portlets</groupId>
<artifactId>parent</artifactId>
<version>1.2.8</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>org.ow2.weblab.portlets</groupId>
<artifactId>weblab-metaview</artifactId>
<version>2.2.1</version>
<packaging>war</packaging>
<name>WebLab Metaview</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<weblab.snapshot.repositoryId>weblab.snapshot</weblab.snapshot.repositoryId>
<weblab.release.repositoryId>weblab.release</weblab.release.repositoryId>
<weblab.snapshot.url>scp://weblab-project.org/home/ipccproj/public_html/maven-snapshot</weblab.snapshot.url>
<weblab.release.url>scp://weblab-project.org/home/ipccproj/public_html/maven</weblab.release.url>
<weblab.repositoryId>${weblab.release.repositoryId}</weblab.repositoryId>
<weblab.url>${weblab.release.url}</weblab.url>
<spring.version>3.0.7.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.weblab.core.helpers</groupId>
<artifactId>rdf-helper-jena</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.weblab.core.helpers</groupId>
<artifactId>rdf-helper-jena-structure</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.weblab.components</groupId>
<artifactId>weblab-taglib</artifactId>
</dependency>
</dependencies>
<description>This portlet displays WebLab resources metadata.</description>
<build>
<finalName>${project.artifactId}</finalName>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.ow2.weblab.components</groupId>
<artifactId>weblab-taglib</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean;
import java.util.Map;
import java.util.TreeMap;
/**
* Class representing a result configuration for meta.
*
* @author emilien
*
*/
public class DisplayMetaConfBean {
private Map<String, Boolean> properties;
public DisplayMetaConfBean() {
this.properties = new TreeMap<>();
}
public Map<String, Boolean> getProperties() {
return this.properties;
}
public void setProperties(Map<String, Boolean> properties) {
this.properties = properties;
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean;
import java.util.List;
import java.util.Map;
public class EditMetaConfBean {
private Map<String, List<String>> properties;
public Map<String, List<String>> getProperties() {
return this.properties;
}
public void setProperties(final Map<String, List<String>> properties) {
this.properties = properties;
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean;
import java.util.Map;
/**
* Bean to store annotations description and it value.
*
* @author emilien
*/
public class RDFPropertiesConfBean {
private Map<String, String> properties;
/**
* @return the properties
*/
public Map<String, String> getProperties() {
return this.properties;
}
/**
* @param properties
* the properties to set
*/
public void setProperties(final Map<String, String> properties) {
this.properties = properties;
}
/**
* @return An array of the property values.
*/
public String[] getDistinctAnnotationsNS() {
return this.properties.values().toArray(new String[this.properties.values().size()]);
}
/**
* get the value for the annotation name-space.
*
* @param namespace
* of annotation
* @return value for this annotation
*/
public String getAnnotationValue(final String namespace) {
return this.properties.get(namespace).toString();
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean;
/**
* A service description bean.
*
* @author emilienbondu
*
*/
public class ServiceDescription {
private String uri,label;
public String getUri() {
return this.uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean;
import java.util.Date;
public class TimeConfig {
private long maxEndDateMS;
public TimeConfig() {
this.setMaxEndDateMS(new Date());
}
public long getMaxEndDateMS() {
return this.maxEndDateMS;
}
public void setMaxEndDateMS(final Date maxEndDateMS) {
this.maxEndDateMS = maxEndDateMS.getTime();
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.bean.taglib;
import java.util.Map;
/**
* A class to load data taglib properties such as formats and languages.
*
* @author kdesir
*/
public class DataTaglib {
private Map<String, String> formats;
private Map<String, String> languages;
public Map<String, String> getLanguages() {
return this.languages;
}
public void setLanguages(final Map<String, String> languages) {
this.languages = languages;
}
public Map<String, String> getFormats() {
return this.formats;
}
public void setFormats(final Map<String, String> formats) {
this.formats = formats;
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.service;
import java.net.URI;
import java.util.Locale;
import java.util.Map;
import org.ow2.weblab.core.model.PieceOfKnowledge;
import org.ow2.weblab.core.model.Resource;
import org.ow2.weblab.core.services.ContentNotAvailableException;
import org.ow2.weblab.core.services.InvalidParameterException;
import org.ow2.weblab.core.services.UnexpectedException;
import org.ow2.weblab.portlet.business.bean.ServiceDescription;
public interface MetaViewBusinessServices {
public Resource getWLResource(final String docURI) throws ContentNotAvailableException, InvalidParameterException, UnexpectedException;
public String getURIFromPoK(final PieceOfKnowledge pok);
public Map<String, ServiceDescription> getTranslations(final Resource res, final Locale prefered);
public PieceOfKnowledge getPoKForSelectedTranslation(final URI uri, final URI serviceURI, final String lang);
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.service.impl;
import java.net.URI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.portlet.ActionRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.ow2.weblab.core.annotator.AbstractAnnotator.Operator;
import org.ow2.weblab.core.annotator.BaseAnnotator;
import org.ow2.weblab.core.model.Resource;
import org.purl.dc.elements.DublinCoreAnnotator;
/**
* A class to edit meta data contained in resources.
*
* @author kdesir
*
*/
public class EditMetaServices {
private final Map<String, List<String>> editMetaConf;
private final Log logger = LogFactory.getLog(this.getClass());
private final String pattern = "MM/dd/yyyy HH:mm";
public EditMetaServices(final Map<String, List<String>> editMeta) {
this.editMetaConf = editMeta;
}
public Map<String, String[]> getParameterMap(final ActionRequest request) {
return request.getParameterMap();
}
/**
* Modify the resource according field that the user have filled.
*
* @param resource
* the current resource to modify
* @param parameterMap
* a map which represents the key-value parameters of the edit
* form
* @return
* the modified resource.
*/
public Resource writeContent(final Resource resource, final Map<String, String[]> parameterMap) {
for (final String keyParam : parameterMap.keySet()) {
if (this.editMetaConf.containsKey(keyParam)) {
final List<String> valueEditConf = this.editMetaConf.get(keyParam);
try {
this.writeWithType(resource, valueEditConf, keyParam, parameterMap);
} catch (final ParseException e) {
this.logger.error("Unable to parse date value, the correct format must be MM/dd/yyyy HH:mm", e);
}
}
}
return resource;
}
/**
* @param resource
* the current resource to modify.
* @param valueEditConf
* the list of value linked with the meta data field such as
* "title" field will have : [dc , http://namespace , string ].
* @param keyParam
* the actual field that will be modified.
* @param parameterMap
* a map which represents the key-value parameters of the edit
* form.
* @throws ParseException
* if the date is not in the right format.
*/
private void writeWithType(final Resource resource, final List<String> valueEditConf, final String keyParam, final Map<String, String[]> parameterMap) throws ParseException {
final String value = parameterMap.get(keyParam)[0];
final String xlmns = valueEditConf.get(0);
final String entireNameSpace = valueEditConf.get(1);
final String valueType = valueEditConf.get(2);
// use the right method according to the key Parameter we have.
if (!value.isEmpty()) {
if (valueType.equals("string")) {
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, String.class, value);
} else if (valueType.equals("long")) {
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, Long.class, Long.valueOf(value));
} else if (valueType.equals("double")) {
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, Double.class, Double.valueOf(value));
} else if (valueType.equals("date")) {
final SimpleDateFormat dateFormat = new SimpleDateFormat(this.pattern);
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, Date.class, dateFormat.parse(value.toString()));
} else if (valueType.equals("integer")) {
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, Integer.class, Integer.valueOf(value));
}
}
// if empty, erase the current field of the resource.
else {
this.write(resource, xlmns, URI.create(entireNameSpace), keyParam, null, null);
}
}
public Map<String, List<String>> getEditMetaConf() {
return this.editMetaConf;
}
/**
*
* @param resource
* the current resource to modify.
* @param prefix
* the prefix
* @param propertyURI
* the namespace of the property.
* @param localname
* the localname of the property.
* @param clazz
* the class of the value
* @param val
* the current value
*/
public <T> void write(final Resource resource, final String prefix, final URI propertyURI, final String localname, final Class<T> clazz, final T val) {
final BaseAnnotator ba = new BaseAnnotator(resource);
if (localname.equals("subject") && (val != null)) {
final DublinCoreAnnotator dc = new DublinCoreAnnotator(resource);
final String[] mySubject = ((String) val).split(",");
ba.setAppendMode(false);
ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, null);
for (final String value : mySubject) {
dc.writeSubject(value.trim());
}
} else {
ba.setAppendMode(false);
ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, null);
ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, val);
}
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*