diff --git a/.classpath b/.classpath
index 9822435..098b190 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,6 @@
-
+
@@ -27,5 +27,5 @@
-
+
diff --git a/META-INF/CkanMetadatas.xml b/META-INF/CkanMetadatas.xml
new file mode 100644
index 0000000..45c9893
--- /dev/null
+++ b/META-INF/CkanMetadatas.xml
@@ -0,0 +1,33 @@
+
+
+
+ Name
+ true
+ Date
+ default value
+ shown as suggestions in the insert/update metadata form of CKAN
+
+ field1
+ field2
+ field3
+
+
+ a regular expression for validating values
+
+
+
+ Accessibility
+ true
+ String
+ virtual/public
+ shown as suggestions in the insert metadata form of CKAN
+
+ virtual/public
+ virtual/private
+ transactional
+
+
+ a regular expression for validating values
+
+
+
diff --git a/pom.xml b/pom.xml
index 6a02d27..038d8d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.data-catalogue
gcubedatacatalogue-metadata-discovery
jar
- 1.0.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
The gCube data catalogue metadata discovery library
The gCube data catalogue metadata discovery library
@@ -64,7 +64,7 @@
ic-client
provided
-
+
org.gcube.core
common-scope-maps
@@ -87,6 +87,7 @@
provided
+
log4j
diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/adapter/DataTypeAdapter.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/adapter/DataTypeAdapter.java
new file mode 100644
index 0000000..7573b8b
--- /dev/null
+++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/adapter/DataTypeAdapter.java
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+
+package org.gcube.datacatalogue.metadatadiscovery.adapter;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType;
+
+
+/**
+ * The Class DataTypeAdapter.
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * Sep 12, 2016
+ */
+public class DataTypeAdapter extends XmlAdapter {
+
+ /* (non-Javadoc)
+ * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
+ */
+ public String marshal(DataType dt) {
+
+ return dt.name();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
+ */
+ public DataType unmarshal(String dt) {
+
+ return DataType.fromValue(dt);
+ }
+}
diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/DataType.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/DataType.java
new file mode 100644
index 0000000..5ac5e1b
--- /dev/null
+++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/DataType.java
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package org.gcube.datacatalogue.metadatadiscovery.bean.jaxb;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * The Enum DataType.
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * Sep 12, 2016
+ */
+@XmlType(name = "datatype")
+@XmlEnum
+public enum DataType {
+
+ String,
+ Date,
+ Text,
+ Boolean,
+ Number;
+
+ /**
+ * Value.
+ *
+ * @return the string
+ */
+ public String value() {
+ return name();
+ }
+
+ /**
+ * From value.
+ *
+ * @param v the v
+ * @return the data type
+ */
+ public static DataType fromValue(String v) {
+ DataType vv;
+ try{
+ vv = valueOf(v);
+ }catch(Exception e){
+ return DataType.String;
+ }
+
+ return vv;
+ }
+}
diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java
index bc4855f..b0ea857 100644
--- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java
+++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java
@@ -9,6 +9,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.gcube.datacatalogue.metadatadiscovery.adapter.DataTypeAdapter;
@@ -25,11 +28,15 @@ public class MetadataField implements Serializable{
/**
*
*/
- private static final long serialVersionUID = 1740491173451633254L;
+ private static final long serialVersionUID = 5935573474465015727L;
+ @XmlElement(required = true)
private String fieldName;
+ @XmlElement(required = true)
private Boolean mandatory = false;
- private Boolean isBoolean = false;
+// private Boolean isBoolean = false;
+ @XmlJavaTypeAdapter(DataTypeAdapter.class)
+ private DataType dataType = DataType.String;
private String defaulValue;
private String note;
@@ -46,37 +53,19 @@ public class MetadataField implements Serializable{
public MetadataField() {
}
-
/**
- * Instantiates a new metadata field.
- *
- * @param fieldName the field name
- * @param mandatory the mandatory
- * @param isBoolean the is boolean
- * @param defaulValue the defaul value
- * @param note the note
- * @param vocabulary the vocabulary
- * @param validator the validator
+ * @param fieldName
+ * @param mandatory
*/
- public MetadataField(
- String fieldName, Boolean mandatory, Boolean isBoolean,
- String defaulValue, String note, MetadataVocabulary vocabulary,
- MetadataValidator validator) {
+ public MetadataField(String fieldName, Boolean mandatory) {
+ super();
this.fieldName = fieldName;
this.mandatory = mandatory;
- this.isBoolean = isBoolean;
- this.defaulValue = defaulValue;
- this.note = note;
- this.vocabulary = vocabulary;
- this.validator = validator;
}
-
/**
- * Gets the field name.
- *
* @return the fieldName
*/
public String getFieldName() {
@@ -85,10 +74,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Gets the mandatory.
- *
* @return the mandatory
*/
public Boolean getMandatory() {
@@ -97,22 +83,16 @@ public class MetadataField implements Serializable{
}
-
/**
- * Gets the checks if is boolean.
- *
- * @return the isBoolean
+ * @return the dataType
*/
- public Boolean getIsBoolean() {
+ public DataType getDataType() {
- return isBoolean;
+ return dataType;
}
-
/**
- * Gets the defaul value.
- *
* @return the defaulValue
*/
public String getDefaulValue() {
@@ -121,10 +101,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Gets the note.
- *
* @return the note
*/
public String getNote() {
@@ -133,10 +110,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Gets the vocabulary.
- *
* @return the vocabulary
*/
public MetadataVocabulary getVocabulary() {
@@ -145,10 +119,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Gets the validator.
- *
* @return the validator
*/
public MetadataValidator getValidator() {
@@ -157,10 +128,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the field name.
- *
* @param fieldName the fieldName to set
*/
public void setFieldName(String fieldName) {
@@ -169,10 +137,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the mandatory.
- *
* @param mandatory the mandatory to set
*/
public void setMandatory(Boolean mandatory) {
@@ -181,22 +146,16 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the checks if is boolean.
- *
- * @param isBoolean the isBoolean to set
+ * @param dataType the dataType to set
*/
- public void setIsBoolean(Boolean isBoolean) {
+ public void setDataType(DataType dataType) {
- this.isBoolean = isBoolean;
+ this.dataType = dataType;
}
-
/**
- * Sets the defaul value.
- *
* @param defaulValue the defaulValue to set
*/
public void setDefaulValue(String defaulValue) {
@@ -205,10 +164,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the note.
- *
* @param note the note to set
*/
public void setNote(String note) {
@@ -217,10 +173,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the vocabulary.
- *
* @param vocabulary the vocabulary to set
*/
public void setVocabulary(MetadataVocabulary vocabulary) {
@@ -229,10 +182,7 @@ public class MetadataField implements Serializable{
}
-
/**
- * Sets the validator.
- *
* @param validator the validator to set
*/
public void setValidator(MetadataValidator validator) {
@@ -240,7 +190,6 @@ public class MetadataField implements Serializable{
this.validator = validator;
}
-
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -252,8 +201,8 @@ public class MetadataField implements Serializable{
builder.append(fieldName);
builder.append(", mandatory=");
builder.append(mandatory);
- builder.append(", isBoolean=");
- builder.append(isBoolean);
+ builder.append(", dataType=");
+ builder.append(dataType);
builder.append(", defaulValue=");
builder.append(defaulValue);
builder.append(", note=");
diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataVocabulary.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataVocabulary.java
index ce079b3..0b5725c 100644
--- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataVocabulary.java
+++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataVocabulary.java
@@ -8,15 +8,15 @@ import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
-
/**
* The Class MetadataVocabulary.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
- * Jun 8, 2016
+ * Sep 12, 2016
*/
@XmlRootElement(name = "metadatavocabulary")
@XmlAccessorType (XmlAccessType.FIELD)
@@ -25,10 +25,13 @@ public class MetadataVocabulary implements Serializable{
/**
*
*/
- private static final long serialVersionUID = 6697274733224694581L;
+ private static final long serialVersionUID = 506451021936766592L;
private List vocabularyField;
+ @XmlAttribute
+ private Boolean isMultiSelection = false;
+
/**
* Instantiates a new metadata vocabulary.
*/
@@ -47,6 +50,18 @@ public class MetadataVocabulary implements Serializable{
this.vocabularyField = vocabularyFields;
}
+ /**
+ * Instantiates a new metadata vocabulary.
+ *
+ * @param vocabularyField the vocabulary field
+ * @param isMultiSelection the is multi selection
+ */
+ public MetadataVocabulary(List vocabularyField, Boolean isMultiSelection) {
+
+ super();
+ this.vocabularyField = vocabularyField;
+ this.isMultiSelection = isMultiSelection;
+ }
/**
@@ -72,6 +87,42 @@ public class MetadataVocabulary implements Serializable{
}
+
+ /**
+ * Gets the vocabulary field.
+ *
+ * @return the vocabularyField
+ */
+ public List getVocabularyField() {
+
+ return vocabularyField;
+ }
+
+
+
+ /**
+ * Checks if is multi selection.
+ *
+ * @return the isMultiSelection
+ */
+ public Boolean isMultiSelection() {
+
+ return isMultiSelection;
+ }
+
+
+
+ /**
+ * Sets the checks if is multi selection.
+ *
+ * @param isMultiSelection the isMultiSelection to set
+ */
+ public void setIsMultiSelection(Boolean isMultiSelection) {
+
+ this.isMultiSelection = isMultiSelection;
+ }
+
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -81,8 +132,12 @@ public class MetadataVocabulary implements Serializable{
StringBuilder builder = new StringBuilder();
builder.append("MetadataVocabulary [vocabularyField=");
builder.append(vocabularyField);
+ builder.append(", isMultiSelection=");
+ builder.append(isMultiSelection);
builder.append("]");
return builder.toString();
}
}
+
+
diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java
index f88b078..9cc451f 100644
--- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java
+++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java
@@ -80,7 +80,7 @@ public class MedataFormatDiscovery {
List appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
- throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure, the scope is "+scopeString);
+ throw new ApplicationProfileNotFoundException("ApplicationProfile with secondaryType: "+secondaryType+" is not registered in the scope: "+scopeString);
else {
for (String elem : appProfile) {
@@ -99,8 +99,6 @@ public class MedataFormatDiscovery {
} catch (Exception e) {
logger.error("Error while trying to fetch applicationProfile "+secondaryType+" from the infrastructure, "+e);
return list;
- } finally{
-// ScopeProvider.instance.reset();
}
return list;
diff --git a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestJaxbMetadataMarshUnmarsh.java b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestJaxbMetadataMarshUnmarsh.java
index 0fa7fa0..7d80b7e 100644
--- a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestJaxbMetadataMarshUnmarsh.java
+++ b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestJaxbMetadataMarshUnmarsh.java
@@ -12,6 +12,7 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataValidator;
@@ -43,12 +44,14 @@ public class TestJaxbMetadataMarshUnmarsh {
ckanMetadata.setFieldName("Name");
ckanMetadata.setMandatory(true);
ckanMetadata.setDefaulValue("default value");
+ ckanMetadata.setDataType(DataType.Date);
List vocabulary = new ArrayList();
vocabulary.add("field1");
vocabulary.add("field2");
vocabulary.add("field3");
MetadataVocabulary cvc = new MetadataVocabulary(vocabulary);
ckanMetadata.setVocabulary(cvc);
+ cvc.setIsMultiSelection(true);
ckanMetadata.setNote("shown as suggestions in the insert/update metadata form of CKAN");
MetadataValidator validator = new MetadataValidator("a regular expression for validating values");
ckanMetadata.setValidator(validator);
@@ -116,7 +119,13 @@ public class TestJaxbMetadataMarshUnmarsh {
for(MetadataField mtd : mtds.getMetadataFields())
{
- System.out.println(mtd);
+ System.out.println("Unmarshall: "+mtd);
}
}
+
+
+ public static void main(String[] args) {
+
+ System.out.println(DataType.valueOf("aa"));
+ }
}