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;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import eu.dnetlib.organizations.model.view.OrganizationView;
|
||||
|
@ -7,4 +9,5 @@ import eu.dnetlib.organizations.model.view.OrganizationView;
|
|||
@Repository
|
||||
public interface OrganizationViewRepository extends ReadOnlyRepository<OrganizationView, String> {
|
||||
|
||||
Optional<OrganizationView> findByOpenaireId(String openaireId);
|
||||
}
|
||||
|
|
|
@ -657,13 +657,28 @@ public class DatabaseUtils {
|
|||
return persistentOrganizationViewRepository.findAll();
|
||||
}
|
||||
|
||||
public void addPersistentOrgs(final String id) {
|
||||
final boolean valid = organizationRepository.findById(id)
|
||||
.map(Organization::getStatus)
|
||||
.filter(s -> s.equals(OrganizationStatus.approved.toString()))
|
||||
.isPresent();
|
||||
public String addPersistentOrgs(final String id) {
|
||||
|
||||
final boolean valid;
|
||||
final String ooid;
|
||||
|
||||
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) {
|
||||
persistentOrganizationRepository.save(new PersistentOrganization(id));
|
||||
persistentOrganizationRepository.save(new PersistentOrganization(ooid));
|
||||
return ooid;
|
||||
} else {
|
||||
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>
|
||||
</p>
|
||||
|
||||
<table class="table table-sm small">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th style="width: 200px">ID</th>
|
||||
<th style="width: 300px">OA Graph Node ID</th>
|
||||
<th>Name</th>
|
||||
<th style="width: 300px">Place</th>
|
||||
<th style="width: 40px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody ng-show="orgs.length > 0">
|
||||
<tr ng-repeat="o in orgs">
|
||||
<td><a href="#!/edit/0/{{o.id}}">{{o.id}}</a></td>
|
||||
<td>{{o.openaireId}}</td>
|
||||
<td>{{o.name}}</td>
|
||||
<td><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city || '-'}}, {{o.country}}</td>
|
||||
<td class="text-right">
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" ng-click="deletePersistentOrg(o.id)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody ng-hide="orgs.length > 0">
|
||||
<tr>
|
||||
<td colspan="5" class="text-muted">No persistent organizazions</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr ng-init="newId=''">
|
||||
<td colspan="4">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="new persistent organization ID..." ng-model="newId" />
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<button type="button" 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>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<input type="text" class="form-control form-control-sm mb-3" ng-model="poFilter" placeholder="Filter...">
|
||||
|
||||
<form>
|
||||
<table class="table table-sm small">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th style="width: 200px">ID</th>
|
||||
<th style="width: 300px">OA Graph Node ID</th>
|
||||
<th>Name</th>
|
||||
<th style="width: 300px">Place</th>
|
||||
<th style="width: 40px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody ng-show="orgs.length > 0">
|
||||
<tr ng-repeat="o in orgs | filter:poFilter">
|
||||
<td><a href="#!/edit/0/{{o.id}}">{{o.id}}</a></td>
|
||||
<td>{{o.openaireId}}</td>
|
||||
<td>{{o.name}}</td>
|
||||
<td><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city || '-'}}, {{o.country}}</td>
|
||||
<td class="text-right">
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" ng-click="deletePersistentOrg(o.id)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody ng-hide="orgs.length > 0">
|
||||
<tr>
|
||||
<td colspan="5" class="text-muted">No persistent organizazions</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr ng-init="newId=''">
|
||||
<td colspan="4">
|
||||
<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" />
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<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