Fixes bug on updating Project entity and various code missteps.
This commit is contained in:
parent
01c5166bb9
commit
e8efe54479
|
@ -12,9 +12,13 @@ import javax.persistence.criteria.JoinType;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service("ProjectDao")
|
||||
@Service("projectDao")
|
||||
public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDao {
|
||||
|
||||
public ProjectDaoImpl(DatabaseService<Project> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> getWithCritetia(ProjectCriteria criteria) {
|
||||
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
|
||||
|
@ -33,10 +37,6 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
return query;
|
||||
}
|
||||
|
||||
public ProjectDaoImpl(DatabaseService<Project> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project createOrUpdate(Project item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, Project.class);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
case 99:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Grant Status");
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
case 1:
|
||||
return INTERNAL;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Grant Type");
|
||||
throw new RuntimeException("Unsupported Project Type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ public class Projects extends BaseController{
|
|||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest grantCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<Project> dataTable = this.projectManager.getCriteriaWithExternal(grantCriteria, principal);
|
||||
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ public class ProjectManager {
|
|||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria, Principal principal) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria, Principal principal) throws HugeResultSet, NoURLFound {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<eu.eudat.data.entities.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
||||
List<Project> projects = authItems.select(item -> new eu.eudat.models.data.project.Project().fromDataModel(item));
|
||||
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike());
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.proxy.fetching;
|
|||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.logic.proxy.config.DataUrlConfiguration;
|
||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||
|
@ -26,11 +27,13 @@ public class RemoteFetcher {
|
|||
private ConfigLoader configLoader;
|
||||
|
||||
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
|
||||
@Autowired
|
||||
public RemoteFetcher(ConfigLoader configLoader, DynamicGrantConfiguration dynamicGrantConfiguration) {
|
||||
public RemoteFetcher(ConfigLoader configLoader, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
this.configLoader = configLoader;
|
||||
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
}
|
||||
|
||||
@Cacheable("repositories")
|
||||
|
@ -51,7 +54,7 @@ public class RemoteFetcher {
|
|||
|
||||
@Cacheable("projects")
|
||||
public List<Map<String, String>> getProjects(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicGrantConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
|
||||
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
|
|
@ -257,6 +257,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
return projectDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setProjectDao(ProjectDao projectDao) {
|
||||
this.projectDao = projectDao;
|
||||
}
|
||||
|
|
|
@ -281,6 +281,26 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
}
|
||||
}
|
||||
|
||||
if (this.project != null) {
|
||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
||||
else {
|
||||
Project project = new Project();
|
||||
project.setAbbreviation("");
|
||||
project.setLabel(this.project.getLabel());
|
||||
project.setType(Project.ProjectType.INTERNAL.getValue());
|
||||
project.setReference("dmp:" + this.project.getLabel());
|
||||
project.setUri("");
|
||||
project.setDefinition("");
|
||||
project.setCreated(new Date());
|
||||
project.setStatus(Project.Status.ACTIVE.getValue());
|
||||
project.setModified(new Date());
|
||||
project.setDescription(this.project.getDescription());
|
||||
|
||||
dataManagementPlanEntity.setProject(project);
|
||||
}
|
||||
}
|
||||
|
||||
dataManagementPlanEntity.setStatus((short) this.status);
|
||||
if (this.status == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||
dataManagementPlanEntity.setFinalizedAt(new Date());
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<configuration>
|
||||
<configurationProperties>
|
||||
<property>
|
||||
<id>field1</id>
|
||||
<name>DMP-EDITOR.FIELDS.PROJECT</name>
|
||||
<sourceUrl>http://localhost:9091/api/project/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<id>field2</id>
|
||||
<queryProperty>funder</queryProperty>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
<property>
|
||||
<id>field2</id>
|
||||
<name>DMP-EDITOR.FIELDS.FUNDER</name>
|
||||
<sourceUrl>http://localhost:9091/api/funder/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
<property>
|
||||
<id>field3</id>
|
||||
<name>DMP-EDITOR.FIELDS.GRANT</name>
|
||||
<sourceUrl>http://localhost:9091/api/grant/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
</configurationProperties>
|
||||
<mainExternalField>
|
||||
<id>field3</id>
|
||||
<name>project.configuration.grant.name</name>
|
||||
<urlConfig>
|
||||
<ordinal>1</ordinal>
|
||||
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
|
||||
<data>
|
||||
<path>$['data'][*]['attributes']</path>
|
||||
<fields>
|
||||
<id>'pid'</id>
|
||||
<name>'name'</name>
|
||||
<uri>'uri'</uri>
|
||||
<description>'description'</description>
|
||||
</fields>
|
||||
</data>
|
||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||
</urlConfig>
|
||||
<externalFieldId>pid</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<language>
|
||||
<languageProperty>
|
||||
<key>navbar</key>
|
||||
<languageKey>NAV-BAR.PROJECTS</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>listingTitle</key>
|
||||
<languageKey>PROJECT-LISTING.TITLE</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>editorTitle</key>
|
||||
<languageKey>PROJECT-EDITOR.TITLE.NEW</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>editorLogo</key>
|
||||
<languageKey>PROJECT-EDITOR.FIELDS.LOGO</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>dmpEditor</key>
|
||||
<languageKey>DMP-EDITOR.FIELDS.PROJECT</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>criteriaStart</key>
|
||||
<languageKey>CRITERIA.PROJECTS.PERIOD-FROM</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>criteriaEnd</key>
|
||||
<languageKey>CRITERIA.PROJECTS.PERIOD-TO</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>dmpCriteria</key>
|
||||
<languageKey>CRITERIA.DMP.PROJECTS</languageKey>
|
||||
</languageProperty>
|
||||
</language>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required></required>
|
||||
</mainExternalField>
|
||||
</configuration>
|
|
@ -16,6 +16,7 @@ pdf.converter.url=http://localhost:88/
|
|||
|
||||
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
|
||||
configuration.externalUrls=/tmp/ExternalUrls.xml
|
||||
configuration.dynamicGrantUrl=/tmp/GrantConfiguration.xml
|
||||
configuration.dynamicProjectUrl=/tmp/ProjectConfiguration.xml
|
||||
configuration.h2020template=C:\\Users\\gkolokythas\\Documents\\openDmp\\dmp-backend\\web\\src\\main\\resources\\documents\\h2020.docx
|
||||
|
||||
|
|
Loading…
Reference in New Issue