From 58ac96b867d118afe8fa9e8615aeb36ee46fb703 Mon Sep 17 00:00:00 2001 From: Keiichiro Ono Date: Tue, 12 Aug 2014 23:13:23 -0700 Subject: [PATCH] More information has been added to columns API. --- .../rest/internal/serializer/GraphObjectSerializer.java | 2 ++ .../java/org/cytoscape/rest/internal/service/JsonTags.java | 1 + .../cytoscape/rest/internal/service/TableDataService.java | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cytoscape/rest/internal/serializer/GraphObjectSerializer.java b/src/main/java/org/cytoscape/rest/internal/serializer/GraphObjectSerializer.java index a1330413..c6f2346c 100644 --- a/src/main/java/org/cytoscape/rest/internal/serializer/GraphObjectSerializer.java +++ b/src/main/java/org/cytoscape/rest/internal/serializer/GraphObjectSerializer.java @@ -119,6 +119,8 @@ public final String serializeColumns(final Collection columns) throws generator.writeStartObject(); generator.writeStringField(JsonTags.COLUMN_NAME, column.getName()); generator.writeStringField(JsonTags.COLUMN_TYPE, column.getType().getSimpleName()); + generator.writeBooleanField(JsonTags.COLUMN_IMMUTABLE, column.isImmutable()); + generator.writeBooleanField(JsonTags.PRIMARY_KEY, column.isPrimaryKey()); generator.writeEndObject(); } generator.writeEndArray(); diff --git a/src/main/java/org/cytoscape/rest/internal/service/JsonTags.java b/src/main/java/org/cytoscape/rest/internal/service/JsonTags.java index 40236147..13e82dbb 100644 --- a/src/main/java/org/cytoscape/rest/internal/service/JsonTags.java +++ b/src/main/java/org/cytoscape/rest/internal/service/JsonTags.java @@ -14,6 +14,7 @@ public class JsonTags { public static final String COLUMN_NAME = "name"; public static final String COLUMN_TYPE = "type"; public static final String COLUMN_VALUES = "values"; + public static final String COLUMN_IMMUTABLE = "immutable"; public static final String TABLE_FORMAT = "format"; } diff --git a/src/main/java/org/cytoscape/rest/internal/service/TableDataService.java b/src/main/java/org/cytoscape/rest/internal/service/TableDataService.java index 69bdbe9a..1bf7cfc9 100644 --- a/src/main/java/org/cytoscape/rest/internal/service/TableDataService.java +++ b/src/main/java/org/cytoscape/rest/internal/service/TableDataService.java @@ -82,7 +82,7 @@ public void createColumn(@PathParam("networkId") Long id, @PathParam("tableType" tableMapper.createNewColumn(rootNode, table); } catch (IOException e) { e.printStackTrace(); - throw new WebApplicationException(e, 500); + throw new WebApplicationException("Could not create column.", e, 500); } } @@ -220,10 +220,11 @@ public String getColumnNames(@PathParam("networkId") Long id, @PathParam("tableT try { return this.serializer.serializeColumns(table.getColumns()); } catch (IOException e) { - throw new WebApplicationException(e, 500); + throw new WebApplicationException("Could not get column names.", e, 500); } } + @GET @Path("/{tableType}/columns/{columnName}") @Produces(MediaType.APPLICATION_JSON)