Fix various issues

This commit is contained in:
George Kalampokis 2021-04-30 13:10:11 +03:00
parent cdae5ae574
commit 8a7cfab3b8
5 changed files with 44 additions and 3 deletions

View File

@ -42,6 +42,13 @@ public class Organisations extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/general/organisations"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Organisation>>> listGeneralOrganisations(@RequestBody OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception {
List<Organisation> organisations = organisationsManager.getWithExternal(organisationsTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/internal/organisations"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception{

View File

@ -66,6 +66,32 @@ public class OrganisationsManager {
return organisationDataTableData;
}
public List<Organisation> getWithExternal(OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception {
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
userInfo.setId(principal.getId());
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
QueryableList<eu.eudat.data.entities.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
QueryableList<eu.eudat.data.entities.Organisation> authItems = organisationDao.getAuthenticated(items, userInfo);
QueryableList<eu.eudat.data.entities.Organisation> pagedItems = PaginationManager.applyPaging(authItems, organisationsTableRequest);
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(organisationsTableRequest.getCriteria().getLabelLike());
List<Map<String, String>> remoteRepos = apiContext.getOperationsContext().getRemoteFetcher().getOrganisations(externalUrlCriteria, null);
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
.name(externalListingItem.getName())
.reference(externalListingItem.getRemoteId())
.tag(externalListingItem.getTag())
.key(externalListingItem.getKey())
.build();
org.add(organisation);
}
return org;
}
public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSet, NoURLFound {
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
List<Map<String, String>> remoteRepos = apiContext.getOperationsContext().getRemoteFetcher().getOrganisations(externalUrlCriteria, type);

View File

@ -95,7 +95,7 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
if (this.key != null) {
if (this.key.toLowerCase().equals("internal")) {
if (this.reference != null) {
researcher.setReference(this.reference);
researcher.setReference("dmp:" + this.reference);
} else {
researcher.setReference("dmp:" + this.id);
}

View File

@ -8,6 +8,8 @@ import { OrganizationModel } from "../../model/organisation/organization";
import { OrganisationCriteria } from "../../query/organisation/organisation-criteria";
import { DataTableRequest } from "../../model/data-table/data-table-request";
import { ConfigurationService } from '../configuration/configuration.service';
import { ExternalSourceItemModel } from "@app/core/model/external-sources/external-source-item";
import { RequestItem } from "@app/core/query/request-item";
@Injectable()
export class OrganisationService {
@ -28,6 +30,10 @@ export class OrganisationService {
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'internal/organisations', dataTableRequest , { headers: this.headers });
}
public searchGeneralOrganisations(dataTableRequest: RequestItem<OrganisationCriteria>): Observable<ExternalSourceItemModel[]> {
return this.http.post<ExternalSourceItemModel[]>(this.actionUrl + 'general/organisations', dataTableRequest , { headers: this.headers });
}
public searchPublicOrganisations(dataTableRequest: DataTableRequest<OrganisationCriteria>): Observable<DataTableData<OrganizationModel>> {
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'public/organisations', dataTableRequest , { headers: this.headers });
}

View File

@ -23,6 +23,7 @@ import { LanguageInfoService } from '@app/core/services/culture/language-info-se
import { UserModel } from '@app/core/model/user/user';
import { AuthService } from '@app/core/services/auth/auth.service';
import { Principal } from '@app/core/model/auth/principal';
import { OrganisationService } from '@app/core/services/organisation/organisation.service';
interface Visible {
value: boolean;
@ -81,7 +82,8 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
private dmpService: DmpService,
private dialog: MatDialog,
private languageInfoService: LanguageInfoService,
private authentication: AuthService
private authentication: AuthService,
private organizationService: OrganisationService
) {
super();
}
@ -145,7 +147,7 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
}
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
return this.externalSourcesService.searchDMPOrganizations(value);
return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value } });
}
cantAddOrganizations(): boolean {