Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add patch for fields display names #983

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN mvn install \
###################
# PACKAGING STAGE #
###################
FROM gisaia/arlas-openjdk-17-distroless:20240821142139
FROM gisaia/arlas-openjdk-17-distroless:20240926175122

# application placed into /opt/app
WORKDIR /opt/app
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-package-only
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###################
# PACKAGING STAGE #
###################
FROM gisaia/arlas-openjdk-17-distroless:20240821142139
FROM gisaia/arlas-openjdk-17-distroless:20240926175122

# application placed into /opt/app
WORKDIR /opt/app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class CollectionReference implements Serializable {
public static final String DISPLAY_NAMES = "display_names";
public static final String COLLECTION_DISPLAY_NAME = "collection";
public static final String FIELD_DISPLAY_NAME = "fields";
public static final String SHAPE_COLUMN_DISPLAY_NAME = "shape_columns";
public static final String ORGANISATIONS = "organisations";
public static final String ORGANISATIONS_OWNER = "owner";
public static final String ORGANISATIONS_SHARED = "shared";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,27 @@ public CollectionReference putCollectionReference(CollectionReference collection
return collectionReference;
}

public CollectionReference updateCollectionDisplayNameCollectionReference(String collection,
String organisations,
String columnFilter, String displayName)
public CollectionReference updateDisplayNamesCollectionReference(String collection, String organisations,String columnFilter,
String collectionDisplayName,
Map<String,String> fieldsDisplayNames,
Map<String,String> shapeColumnsDisplayNames)
throws ArlasException {
CollectionReference collectionReference = getCollectionReference(collection, Optional.ofNullable(organisations));
ColumnFilterUtil.assertCollectionsAllowed(Optional.ofNullable(columnFilter), List.of(collectionReference));
checkIfAllowedForOrganisations(collectionReference, Optional.ofNullable(organisations), true);
if (collectionReference.params.collectionDisplayNames == null) {
collectionReference.params.collectionDisplayNames = new CollectionDisplayNames();
}
collectionReference.params.collectionDisplayNames.collection = displayName;
putCollectionReferenceWithDao(collectionReference);
cacheManager.removeCollectionReference(collectionReference.collectionName);
cacheManager.removeMapping(collectionReference.params.indexName);
return collectionReference;
if(fieldsDisplayNames != null){
collectionReference.params.collectionDisplayNames.fields = fieldsDisplayNames;
}
if(shapeColumnsDisplayNames != null){
collectionReference.params.collectionDisplayNames.shapeColumns = shapeColumnsDisplayNames;
}
if(collectionDisplayName != null){
collectionReference.params.collectionDisplayNames.collection = collectionDisplayName;
}
return putCollectionReference(collectionReference, true);
}

public CollectionReference updateOrganisationsParamsCollectionReference(String collection,
Expand All @@ -137,10 +143,7 @@ public CollectionReference updateOrganisationsParamsCollectionReference(String c
checkIfAllowedForOrganisations(collectionReference, Optional.ofNullable(organisations), true);
collectionReference.params.collectionOrganisations.isPublic = isPublic;
collectionReference.params.collectionOrganisations.sharedWith = sharedWith;
putCollectionReferenceWithDao(collectionReference);
cacheManager.removeCollectionReference(collectionReference.collectionName);
cacheManager.removeMapping(collectionReference.params.indexName);
return collectionReference;
return putCollectionReference(collectionReference, true);
}

public List<CollectionReferenceDescription> describeAllCollections(List<CollectionReference> collectionReferenceList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,110 @@ public Response patchCollectionDisplayName(
if (collection != null && collection.equals(META_COLLECTION_NAME)) {
throw new NotAllowedException("'" + META_COLLECTION_NAME + "' cannot be updated");
}
return ResponseFormatter.getResultResponse(collectionReferenceService.updateCollectionDisplayNameCollectionReference(collection, organisations, columnFilter,collectionDisplayName ));
return ResponseFormatter.getResultResponse(collectionReferenceService.updateDisplayNamesCollectionReference(collection, organisations, columnFilter,collectionDisplayName, null, null ));
}


@Timed
@Path("{collection}/display_names/fields")
@PATCH
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@Operation(
summary = "Update a collection reference's display fields name attribute.",
description = "Update a collection reference's display fields name attribute."
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = CollectionReference.class))),
@ApiResponse(responseCode = "400", description = "JSON parameter malformed.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "404", description = "Collection not found.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class)))
})
public Response patchFieldsDisplayNames(
@Context HttpHeaders headers,
@Parameter(name = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,

@Parameter(name = "fieldsDisplayNames",
description = "fieldsDisplayNames",
required = true)
@NotNull Map<String,String> fieldsDisplayNames,

@Parameter(hidden = true)
@HeaderParam(value = COLUMN_FILTER) String columnFilter,

@Parameter(hidden = true)
@HeaderParam(value = ARLAS_ORGANISATION) String organisations,
// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@Parameter(name = "pretty",
description = Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value = "pretty") Boolean pretty

) throws ArlasException {
if (collection != null && collection.equals(META_COLLECTION_NAME)) {
throw new NotAllowedException("'" + META_COLLECTION_NAME + "' cannot be updated");
}
return ResponseFormatter.getResultResponse(collectionReferenceService.updateDisplayNamesCollectionReference(collection, organisations, columnFilter, null, fieldsDisplayNames, null ));
}

@Timed
@Path("{collection}/display_names/shape_columns")
@PATCH
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@Operation(
summary = "Update a collection reference's display shape columns name attribute.",
description = "Update a collection reference's display shape columns name attribute."
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = CollectionReference.class))),
@ApiResponse(responseCode = "400", description = "JSON parameter malformed.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "404", description = "Collection not found.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class)))
})
public Response patchShapeColumnsDisplayNames(
@Context HttpHeaders headers,
@Parameter(name = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,

@Parameter(name = "shapeColumnsDisplayNames",
description = "shapeColumnsDisplayNames",
required = true)
@NotNull Map<String,String> shapeColumnsDisplayNames,

@Parameter(hidden = true)
@HeaderParam(value = COLUMN_FILTER) String columnFilter,

@Parameter(hidden = true)
@HeaderParam(value = ARLAS_ORGANISATION) String organisations,
// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@Parameter(name = "pretty",
description = Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value = "pretty") Boolean pretty

) throws ArlasException {
if (collection != null && collection.equals(META_COLLECTION_NAME)) {
throw new NotAllowedException("'" + META_COLLECTION_NAME + "' cannot be updated");
}
return ResponseFormatter.getResultResponse(collectionReferenceService.updateDisplayNamesCollectionReference(collection, organisations, columnFilter,null,null,shapeColumnsDisplayNames ));
}

public CollectionReference save(String collection, CollectionReferenceParameters collectionReferenceParameters,
Expand Down
Loading
Loading