in data-resource-management-service/drms-rdbms-impl/drms-server/src/main/java/org/apache/airavata/drms/api/persistance/mapper/ResourceMapper.java [94:143]
public static Resource map(GenericResource resource, Resource exResource, Entity entity,
AuthenticatedUser authenticatedUser) {
Map<Descriptors.FieldDescriptor, Object> allFields = resource.getAllFields();
Set<ResourceProperty> resourcePropertySet = new HashSet<>();
Resource prResource = new Resource();
Map<String,String> resourceMap = resource.getPropertiesMap();
for(Map.Entry<String,String> entry: resourceMap.entrySet()){
resourcePropertySet.add(new ResourceProperty(entry.getKey(), entry.getValue(), prResource));
}
if (allFields != null) {
allFields.forEach((descriptor, value) -> {
String fieldName = descriptor.getJsonName();
ResourceProperty resourceProperty = new ResourceProperty(fieldName, value.toString(), prResource);
resourcePropertySet.add(resourceProperty);
});
}
resourcePropertySet.add(new ResourceProperty("description", entity.getDescription(), prResource));
resourcePropertySet.add(new ResourceProperty("resourceName", entity.getName(), prResource));
resourcePropertySet.add(new ResourceProperty("createdTime", String.valueOf(entity.getCreatedAt()), prResource));
resourcePropertySet.add(new ResourceProperty("tenantId", authenticatedUser.getTenantId(), prResource));
resourcePropertySet.add(new ResourceProperty("lastModifiedTime", String.valueOf(entity.getCreatedAt()), prResource));
resourcePropertySet.add(new ResourceProperty("owner", entity.getOwnerId(), prResource));
if(exResource != null){
Set<ResourceProperty> properties = exResource.getResourceProperty();
for(ResourceProperty property: properties){
if (property.getPropertyKey().equals("metadata")||
property.getPropertyKey().equals("firstName")||
property.getPropertyKey().equals("lastName")){
resourcePropertySet.add(property);
}
}
}
prResource.setId(entity.getId());
prResource.setResourceProperty(resourcePropertySet);
prResource.setTenantId(authenticatedUser.getTenantId());
prResource.setResourceProperty(resourcePropertySet);
prResource.setSourceTransferMapping(new HashSet<>());
prResource.setDestinationTransferMapping(new HashSet<>());
return prResource;
}