Skip to content

Commit

Permalink
[BugFix] Variable group selector
Browse files Browse the repository at this point in the history
  • Loading branch information
MAUSSANG BRICE committed Sep 28, 2023
1 parent 4ab1fa1 commit 40dfd0f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

import com.fasterxml.jackson.annotation.JsonProperty;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.opensilex.core.variable.dal.VariableModel;
import org.opensilex.core.variablesGroup.dal.VariablesGroupModel;
import org.opensilex.sparql.deserializer.SPARQLDeserializers;
import org.opensilex.sparql.response.NamedResourceDTO;

/**
Expand All @@ -35,7 +38,11 @@ public static VariablesGroupGetDTO fromModel(VariablesGroupModel model) {

VariablesGroupGetDTO dto = new VariablesGroupGetDTO();

dto.setUri(model.getUri());
try {
dto.setUri(new URI(SPARQLDeserializers.getShortURI(model.getUri())));
} catch (URISyntaxException e) {
dto.setUri(model.getUri());
}
dto.setName(model.getName());
dto.setDescription(model.getDescription());
if (Objects.nonNull(model.getPublicationDate())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ import { EventGetDTO, ProvenanceGetDTO } from "opensilex-core/index";
import HttpResponse, { OpenSilexResponse } from "opensilex-core/HttpResponse";
import { ScientificObjectsService } from "opensilex-core/index";
import {ScientificObjectDetailDTO} from "opensilex-core/model/scientificObjectDetailDTO";
import UsedScientificObjectSelector from 'src/components/scientificObjects/views/UsedScientificObjectSelector.vue';
import UsedScientificObjectSelector from "../../scientificObjects/views/UsedScientificObjectSelector.vue";
let lastWeekDate = new Date(new Date((new Date).setDate(new Date().getDate() - 7)).setHours(0,0,0,0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
>
</opensilex-UriListView>

<!-- VariableGroups -->
<opensilex-UriListView
v-if="hasVariableGroups"
label="FacilityDescription.variable-groups"
:list="variableGroupUriList"
:inline="true"
>
</opensilex-UriListView>

<!-- Devices -->
<opensilex-UriListView
v-if="hasDevices"
Expand Down Expand Up @@ -185,6 +194,10 @@ export default class FacilityDescription extends Vue {
return !!this.experiments && this.experiments.length > 0;
}
get hasVariableGroups() {
return !!this.selected && this.selected.variableGroups.length > 0;
}
get hasDevices() {
return !!this.devices && this.devices.length > 0;
}
Expand Down Expand Up @@ -256,6 +269,21 @@ export default class FacilityDescription extends Vue {
});
}
get variableGroupUriList() {
if (!this.selected) {
return [];
}
return this.selected.variableGroups.map(varGroup => {
return {
uri: varGroup.uri,
value: varGroup.name,
to: {
path: "/variables?elementType=VariableGroup&selected=" + encodeURIComponent(varGroup.uri),
},
};
});
}
editOrganizationFacility() {
this.organizationFacilityForm.showEditForm(DTOConverter.extractURIFromResourceProperties(this.selected));
}
Expand Down Expand Up @@ -288,13 +316,16 @@ en:
FacilityDescription:
organizations: Organizations
expsInProgress: Experiments in progress
variable-groups: Groups of variables
devices: Devices
site: "Site"
address: "Address"

fr:
FacilityDescription:
organizations: Organisations
expsInProgress: Experiences en cours
variable-groups: Groupes de variables
devices: Appareils
site: "Site"
address: "Adresse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,6 @@ fr:
no-variable: Aucune variable environnementale trouvée
start-date-help: Date de début des données affichées
end-date-help: Date de fin des données affichées
variable-group-help: Les groupes de variables associées à l'infrastructure. Vous pouvez associer des groupes dans le formulaire de modification de l'infrastructure.
variable-group-help: Les groupes de variables associées à l'installation. Vous pouvez associer des groupes dans le formulaire de modification de l'installation.

</i18n>
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import OpenSilexVuePlugin from "../../models/OpenSilexVuePlugin";
import {VariablesService} from "opensilex-core/api/variables.service";
import SelectForm from "../common/forms/SelectForm.vue";
@Component
export default class GroupVariablesSelector extends Vue {
$opensilex: OpenSilexVuePlugin;
@PropSync("variableGroup")
@PropSync("variableGroup", {default: () => []})
vgURI;
@Prop()
Expand Down Expand Up @@ -57,18 +58,18 @@ export default class GroupVariablesSelector extends Vue {
: "component.groupVariable.form.selector.placeholder";
}
loadVariablesGroups(vg): Promise<Array<VariablesGroupGetDTO>> {
loadVariablesGroups(vgUris): Promise<Array<VariablesGroupGetDTO>> {
return this.$opensilex.getService<VariablesService>("opensilex.VariablesService")
.getVariablesGroupByURIs(vg, this.sharedResourceInstance)
.getVariablesGroupByURIs(vgUris, this.sharedResourceInstance)
.then((http: HttpResponse<OpenSilexResponse<Array<VariablesGroupGetDTO>>>) => {
return http.response.result;
})
.catch(this.$opensilex.errorHandler);
.catch(this.$opensilex.errorHandler);
}
searchVariablesGroups(name): Promise<HttpResponse<OpenSilexResponse<Array<VariablesGroupGetDTO>>>> {
searchVariablesGroups(searchQuery, page, pageSize): Promise<HttpResponse<OpenSilexResponse<Array<VariablesGroupGetDTO>>>> {
return this.$opensilex.getService<VariablesService>("opensilex.VariablesService")
.searchVariablesGroups(name, undefined, ["name=asc"], 0, 10, this.sharedResourceInstance)
.searchVariablesGroups(searchQuery, undefined, ["name=asc"], page, pageSize, this.sharedResourceInstance)
.then((http: HttpResponse<OpenSilexResponse<Array<VariablesGroupGetDTO>>>) => {
return http;
});
Expand Down Expand Up @@ -100,7 +101,6 @@ en:
placeholder : Select one group of variables
placeholder-multiple : Select one or more groups of variables
filter-search-no-result : No groups of variables found


fr:
component:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { Component, Prop, PropSync, Ref } from "vue-property-decorator";
import Vue from "vue";
import {ScientificObjectsService} from "opensilex-core/index";
import SelectForm, { SelectableItem } from 'src/components/common/forms/SelectForm.vue';
import SelectForm, { SelectableItem } from "../../common/forms/SelectForm.vue";
/**
* Selector of Scientific Objects present in an experiment.
Expand Down

0 comments on commit 40dfd0f

Please sign in to comment.