Fixed metadata parsing
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@131428 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7231aa455b
commit
780eac0d9b
|
@ -334,6 +334,7 @@ public class Utils {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// set the scope
|
// set the scope
|
||||||
|
if(oldScope != scopeInWhichDiscover)
|
||||||
ScopeProvider.instance.set(scopeInWhichDiscover);
|
ScopeProvider.instance.set(scopeInWhichDiscover);
|
||||||
|
|
||||||
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
||||||
|
@ -358,11 +359,10 @@ public class Utils {
|
||||||
wrapperObj.setValidator(validator.getRegularExpression());
|
wrapperObj.setValidator(validator.getRegularExpression());
|
||||||
|
|
||||||
MetadataVocabulary vocabulary = metadataField.getVocabulary();
|
MetadataVocabulary vocabulary = metadataField.getVocabulary();
|
||||||
if(vocabulary != null)
|
if(vocabulary != null){
|
||||||
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
|
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
|
||||||
|
wrapperObj.setMultiSelection(vocabulary.isMultiSelection());
|
||||||
// multi selection?
|
}
|
||||||
wrapperObj.setMultiSelection(metadataField.getVocabulary().isMultiSelection());
|
|
||||||
|
|
||||||
// add to the list
|
// add to the list
|
||||||
wrapperList.add(wrapperObj);
|
wrapperList.add(wrapperObj);
|
||||||
|
@ -385,7 +385,9 @@ public class Utils {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error while retrieving metadata beans ", e);
|
logger.error("Error while retrieving metadata beans ", e);
|
||||||
}finally{
|
}finally{
|
||||||
|
|
||||||
// set the scope back
|
// set the scope back
|
||||||
|
if(oldScope != scopeInWhichDiscover)
|
||||||
ScopeProvider.instance.set(oldScope);
|
ScopeProvider.instance.set(oldScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,87 @@
|
||||||
package org.gcube.portlets.widgets.ckandatapublisherwidget.client;
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataValidator;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataVocabulary;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DataType;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestClass {
|
public class TestClass {
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void testUser() {
|
public void testUser() {
|
||||||
|
|
||||||
assert(new CKANPublisherServicesImpl().getDevelopmentUser().equals(CKANPublisherServicesImpl.TEST_USER));
|
assert(new CKANPublisherServicesImpl().getDevelopmentUser().equals(CKANPublisherServicesImpl.TEST_USER));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMetadata(){
|
||||||
|
|
||||||
|
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
|
||||||
|
try {
|
||||||
|
|
||||||
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
|
|
||||||
|
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
||||||
|
|
||||||
|
for (MetadataType mt : reader.getListOfMetadataTypes()) {
|
||||||
|
MetadataFormat metadata = reader.getMetadataFormatForMetadataType(mt);
|
||||||
|
|
||||||
|
// we need to wrap the list of metadata
|
||||||
|
List<MetadataFieldWrapper> wrapperList = new ArrayList<MetadataFieldWrapper>();
|
||||||
|
List<MetadataField> toWrap = metadata.getMetadataFields();
|
||||||
|
for(MetadataField metadataField: toWrap){
|
||||||
|
|
||||||
|
System.out.println(metadataField.toString());
|
||||||
|
|
||||||
|
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
|
||||||
|
wrapperObj.setDefaultValue(metadataField.getDefaulValue());
|
||||||
|
wrapperObj.setFieldName(metadataField.getFieldName());
|
||||||
|
wrapperObj.setType(DataType.valueOf(metadataField.getDataType().toString()));
|
||||||
|
wrapperObj.setMandatory(metadataField.getMandatory());
|
||||||
|
wrapperObj.setNote(metadataField.getNote());
|
||||||
|
|
||||||
|
MetadataValidator validator = metadataField.getValidator();
|
||||||
|
if(validator != null)
|
||||||
|
wrapperObj.setValidator(validator.getRegularExpression());
|
||||||
|
|
||||||
|
MetadataVocabulary vocabulary = metadataField.getVocabulary();
|
||||||
|
if(vocabulary != null){
|
||||||
|
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
|
||||||
|
wrapperObj.setMultiSelection(vocabulary.isMultiSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
// add to the list
|
||||||
|
wrapperList.add(wrapperObj);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap the mt as well
|
||||||
|
MetaDataTypeWrapper typeWrapper = new MetaDataTypeWrapper();
|
||||||
|
typeWrapper.setDescription(mt.getDescription());
|
||||||
|
typeWrapper.setId(mt.getId());
|
||||||
|
typeWrapper.setName(mt.getName());
|
||||||
|
MetaDataProfileBean bean = new MetaDataProfileBean(typeWrapper, wrapperList);
|
||||||
|
beans.add(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("List of beans is " + beans);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Error while retrieving metadata beans " + e);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue