ckan-metadata-publisher-widget/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/PublisherCatalogueConveter....

56 lines
1.8 KiB
Java
Raw Normal View History

2024-02-12 12:04:29 +01:00
package org.gcube.portlets.widgets.ckandatapublisherwidget.server;
import org.gcube.datacatalogue.utillibrary.shared.ResourceBean;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
2024-02-12 16:52:06 +01:00
/**
* The Class PublisherCatalogueConveter.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 12, 2024
*/
2024-02-12 12:04:29 +01:00
public class PublisherCatalogueConveter {
/**
* To resource element bean.
*
2024-02-12 16:52:06 +01:00
* @param ckanResource the ckan resource
* @param orgNameParent the org name parent
2024-02-12 12:04:29 +01:00
* @return the resource element bean
*/
2024-02-12 16:52:06 +01:00
public static ResourceElementBean toResourceElementBean(CkanResource ckanResource, String orgNameParent) {
2024-02-12 12:04:29 +01:00
ResourceElementBean reb = new ResourceElementBean();
2024-02-12 16:52:06 +01:00
reb.setCkanResourceID(ckanResource.getId());
2024-02-12 12:04:29 +01:00
reb.setName(ckanResource.getName());
reb.setDescription(ckanResource.getDescription());
reb.setEditableName(ckanResource.getName());
reb.setUrl(ckanResource.getUrl());
reb.setMimeType(ckanResource.getMimetype());
2024-02-12 16:52:06 +01:00
reb.setOrganizationNameDatasetParent(orgNameParent);
2024-02-14 11:24:57 +01:00
reb.setCkanDatasetId(ckanResource.getPackageId());
2024-02-12 12:04:29 +01:00
return reb;
}
/**
* To resource bean.
*
2024-02-12 16:52:06 +01:00
* @param ckanResource the ckan resource
* @param orgNameParent the org name parent
2024-02-12 12:04:29 +01:00
* @return the resource bean
*/
2024-02-12 16:52:06 +01:00
public static ResourceBean toResourceBean(CkanResource ckanResource, String orgNameParent) {
2024-02-12 12:04:29 +01:00
ResourceBean reb = new ResourceBean();
reb.setName(ckanResource.getName());
reb.setDescription(ckanResource.getDescription());
reb.setId(ckanResource.getId());
reb.setUrl(ckanResource.getUrl());
reb.setMimeType(ckanResource.getMimetype());
reb.setOwner(ckanResource.getOwner());
reb.setDatasetId(ckanResource.getPackageId());
return reb;
}
}