Moved to 1.1.0-SNAPSHOT. Added getProfilesInTheScopeForName

This commit is contained in:
Francesco Mangiacrapa 2022-03-02 13:24:58 +01:00
parent 465c0b4db7
commit 731cac1e95
7 changed files with 116 additions and 12 deletions

View File

@ -28,11 +28,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -4,17 +4,23 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.0-SNAPSHOT] - 2022-03-01
#### Enhancement
- [#22890] Overloaded the method getProfilesInTheScope
## [v1.0.1-SNAPSHOT] - 2020-10-08
#### Bug fixes
[#20446] Catalogue Publishing Widget: field value unexpectedly added in case of optional field
- [#20446] Catalogue Publishing Widget: field value unexpectedly added in case of optional field
## [v1.0.0] - 2020-10-08
#### First release
[#19884] Create widget to build a data-entry form by using metadata-profile-discovery
- [#19884] Create widget to build a data-entry form by using metadata-profile-discovery
[#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile"
- [#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile"

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>
<packaging>jar</packaging>
<version>1.0.1-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>Metadata Profile Form Builder</name>
<description>
The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s"

View File

@ -8,7 +8,6 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
// TODO: Auto-generated Javadoc
/**
* The client side stub for the RPC service.
*
@ -54,4 +53,15 @@ public interface MetadataProfileFormBuilderService extends RemoteService {
* @throws Exception the exception
*/
Integer purgeFilesUploaded() throws Exception;
/**
* Gets the profiles in the scope.
*
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type
* @param resourceName the resource name
* @return the profiles in the scope
* @throws Exception the exception
*/
List<MetaDataProfileBean> getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception;
}

View File

@ -42,4 +42,7 @@ public interface MetadataProfileFormBuilderServiceAsync {
void getUploadStatus(String clientUploadKey, AsyncCallback<FileUploadingState> asyncCallback);
void purgeFilesUploaded(AsyncCallback<Integer> callback);
void getProfilesInTheScopeForName(String scope, String genericResourceSecondaryType, String resourceName,
AsyncCallback<List<MetaDataProfileBean>> callback);
}

View File

@ -75,6 +75,63 @@ public class MetadataDiscovery {
}
/**
* Gets the metadata profiles list.
*
* @param scope the scope
* @param gRSecondaryType the g R secondary type
* @param resourceName the resource name
* @return the metadata profiles list
* @throws Exception the exception
*/
public static List<MetaDataProfileBean> getMetadataProfilesList(String scope, String gRSecondaryType, String resourceName)
throws Exception {
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
LOG.debug("Discovering into scope " + scope);
String currentContext = ScopeProvider.instance.get();
try {
ScopeProvider.instance.set(scope);
// TODO two reset methods could be added to force the reader to read again these
// information (after a while)
MetadataProfileReader reader = new MetadataProfileReader(gRSecondaryType, resourceName);
List<MetadataProfile> profiles = reader.getListOfMetadataProfiles();
prettyPrintProfiles(profiles);
LOG.info("Profiles are " + profiles.size());
List<NamespaceCategory> categories = reader.getListOfNamespaceCategories();
if (categories == null)
categories = new ArrayList<NamespaceCategory>();
LOG.debug("All Categories are " + categories);
for (MetadataProfile profile : profiles) {
LOG.debug("Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType());
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
beans.add(bean);
}
prettyPrintList(beans);
LOG.info("Returning " + beans.size() + " profile/s");
} catch (Exception e) {
LOG.error("Error while retrieving metadata beans ", e);
throw new Exception("Failed to parse Types: " + e.getMessage());
} finally {
ScopeProvider.instance.set(currentContext);
}
return beans;
}
/**
* Gets the metadata profiles list.
*

View File

@ -66,6 +66,40 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet
return toReturn;
}
/**
* Gets the profiles in the scope.
*
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type
* @param resourceName the resource name
* @return the profiles in the scope
* @throws Exception the exception
*/
@Override
public List<MetaDataProfileBean> getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception {
LOG.info("Called getProfilesInTheScope with parameter scope: " +scope+ ", genericResourceSecondaryType: "+genericResourceSecondaryType, "resourceName: "+resourceName);
if(genericResourceSecondaryType==null || genericResourceSecondaryType.isEmpty())
throw new Exception("The input parameter 'genericResourceSecondaryType' is not valid");
if(resourceName==null || resourceName.isEmpty())
throw new Exception("The input parameter 'resourceName' is not valid");
List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>();
try {
String evaluatedScope = scope == null || scope.isEmpty()?ScopeProvider.instance.get():scope;
LOG.debug("Evaluated scope is " + scope);
toReturn = MetadataDiscovery.getMetadataProfilesList(evaluatedScope, genericResourceSecondaryType, resourceName);
} catch (Exception e) {
LOG.error("Failed to retrieve profiles for scope " +scope, e);
throw e;
}
return toReturn;
}
/**
* Gets the profile for metadata.
*
@ -132,7 +166,7 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet
/**
* Purge files uploaded in the current session
* Purge files uploaded in the current session.
*
* @return number of files deleted. Null otherwise.
* @throws Exception the exception