Skip to content

Commit

Permalink
Merge pull request #983 from gisaia/feature/addPatchCollection
Browse files Browse the repository at this point in the history
Feat: add patch for fields display names
  • Loading branch information
mbarbet authored Sep 27, 2024
2 parents c8406a0 + 3b0aec1 commit a6bf6c3
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 16 deletions.
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

0 comments on commit a6bf6c3

Please sign in to comment.