persistent orgs filter and creation using OpenaireIDs
This commit is contained in:
parent
91d341c7be
commit
39d335439f
|
@ -1,5 +1,7 @@
|
||||||
package eu.dnetlib.organizations.repository.readonly;
|
package eu.dnetlib.organizations.repository.readonly;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import eu.dnetlib.organizations.model.view.OrganizationView;
|
import eu.dnetlib.organizations.model.view.OrganizationView;
|
||||||
|
@ -7,4 +9,5 @@ import eu.dnetlib.organizations.model.view.OrganizationView;
|
||||||
@Repository
|
@Repository
|
||||||
public interface OrganizationViewRepository extends ReadOnlyRepository<OrganizationView, String> {
|
public interface OrganizationViewRepository extends ReadOnlyRepository<OrganizationView, String> {
|
||||||
|
|
||||||
|
Optional<OrganizationView> findByOpenaireId(String openaireId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,13 +657,28 @@ public class DatabaseUtils {
|
||||||
return persistentOrganizationViewRepository.findAll();
|
return persistentOrganizationViewRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPersistentOrgs(final String id) {
|
public String addPersistentOrgs(final String id) {
|
||||||
final boolean valid = organizationRepository.findById(id)
|
|
||||||
.map(Organization::getStatus)
|
final boolean valid;
|
||||||
.filter(s -> s.equals(OrganizationStatus.approved.toString()))
|
final String ooid;
|
||||||
.isPresent();
|
|
||||||
|
if (id.length() == 46) {
|
||||||
|
final Optional<OrganizationView> orgView = organizationViewRepository.findByOpenaireId(id);
|
||||||
|
valid = orgView.map(OrganizationView::getStatus)
|
||||||
|
.filter(s -> s.equals(OrganizationStatus.approved.toString()))
|
||||||
|
.isPresent();
|
||||||
|
ooid = orgView.get().getId();
|
||||||
|
} else {
|
||||||
|
valid = organizationRepository.findById(id)
|
||||||
|
.map(Organization::getStatus)
|
||||||
|
.filter(s -> s.equals(OrganizationStatus.approved.toString()))
|
||||||
|
.isPresent();
|
||||||
|
ooid = id;
|
||||||
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
persistentOrganizationRepository.save(new PersistentOrganization(id));
|
persistentOrganizationRepository.save(new PersistentOrganization(ooid));
|
||||||
|
return ooid;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("The ID does not refer to an approved Organization");
|
throw new RuntimeException("The ID does not refer to an approved Organization");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,44 +4,53 @@
|
||||||
<small>It is necessary to persist the identifiers of the organizations associated to an Institutional Dashboard</small>
|
<small>It is necessary to persist the identifiers of the organizations associated to an Institutional Dashboard</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="table table-sm small">
|
|
||||||
<thead class="thead-light">
|
<div class="row">
|
||||||
<tr>
|
<div class="col-sm-12">
|
||||||
<th style="width: 200px">ID</th>
|
<input type="text" class="form-control form-control-sm mb-3" ng-model="poFilter" placeholder="Filter...">
|
||||||
<th style="width: 300px">OA Graph Node ID</th>
|
|
||||||
<th>Name</th>
|
<form>
|
||||||
<th style="width: 300px">Place</th>
|
<table class="table table-sm small">
|
||||||
<th style="width: 40px"></th>
|
<thead class="thead-light">
|
||||||
</tr>
|
<tr>
|
||||||
</thead>
|
<th style="width: 200px">ID</th>
|
||||||
<tbody ng-show="orgs.length > 0">
|
<th style="width: 300px">OA Graph Node ID</th>
|
||||||
<tr ng-repeat="o in orgs">
|
<th>Name</th>
|
||||||
<td><a href="#!/edit/0/{{o.id}}">{{o.id}}</a></td>
|
<th style="width: 300px">Place</th>
|
||||||
<td>{{o.openaireId}}</td>
|
<th style="width: 40px"></th>
|
||||||
<td>{{o.name}}</td>
|
</tr>
|
||||||
<td><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city || '-'}}, {{o.country}}</td>
|
</thead>
|
||||||
<td class="text-right">
|
<tbody ng-show="orgs.length > 0">
|
||||||
<button type="button" class="btn btn-sm btn-outline-danger" ng-click="deletePersistentOrg(o.id)">
|
<tr ng-repeat="o in orgs | filter:poFilter">
|
||||||
<i class="fa fa-trash"></i>
|
<td><a href="#!/edit/0/{{o.id}}">{{o.id}}</a></td>
|
||||||
</button>
|
<td>{{o.openaireId}}</td>
|
||||||
</td>
|
<td>{{o.name}}</td>
|
||||||
</tr>
|
<td><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city || '-'}}, {{o.country}}</td>
|
||||||
</tbody>
|
<td class="text-right">
|
||||||
<tbody ng-hide="orgs.length > 0">
|
<button type="button" class="btn btn-sm btn-outline-danger" ng-click="deletePersistentOrg(o.id)">
|
||||||
<tr>
|
<i class="fa fa-trash"></i>
|
||||||
<td colspan="5" class="text-muted">No persistent organizazions</td>
|
</button>
|
||||||
</tr>
|
</td>
|
||||||
</tbody>
|
</tr>
|
||||||
<tfoot>
|
</tbody>
|
||||||
<tr ng-init="newId=''">
|
<tbody ng-hide="orgs.length > 0">
|
||||||
<td colspan="4">
|
<tr>
|
||||||
<input type="text" class="form-control form-control-sm" placeholder="new persistent organization ID..." ng-model="newId" />
|
<td colspan="5" class="text-muted">No persistent organizazions</td>
|
||||||
</td>
|
</tr>
|
||||||
<td class="text-right">
|
</tbody>
|
||||||
<button type="button" class="btn btn-sm btn-outline-success" ng-click="addPersistentOrg(newId); newId=''" ng-disabled="!newId">
|
<tfoot>
|
||||||
<i class="fa fa-plus"></i>
|
<tr ng-init="newId=''">
|
||||||
</button>
|
<td colspan="4">
|
||||||
</td>
|
<input type="text" class="form-control form-control-sm" placeholder="example: openorgs____::0123456789 (OpenOrgs ID, 24 chars) or openorgs____::781e5e245d69b566979b86e28d23f2c7 (OA Graph Node ID, 64 chars) ..." ng-model="newId" />
|
||||||
</tr>
|
</td>
|
||||||
</tfoot>
|
<td class="text-right">
|
||||||
</table>
|
<button type="submit" class="btn btn-sm btn-outline-success" ng-click="addPersistentOrg(newId); newId=''" ng-disabled="!newId">
|
||||||
|
<i class="fa fa-plus"></i>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue