-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make warehouse serializable and pagable
- Loading branch information
Showing
12 changed files
with
221 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
package com.gooddata.warehouse; | ||
|
||
import org.codehaus.jackson.annotate.JsonCreator; | ||
import com.gooddata.collections.PageableList; | ||
import com.gooddata.collections.PageableListSerializer; | ||
import com.gooddata.collections.Paging; | ||
import org.codehaus.jackson.annotate.JsonIgnoreProperties; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
import org.codehaus.jackson.annotate.JsonTypeInfo; | ||
import org.codehaus.jackson.annotate.JsonTypeName; | ||
import org.codehaus.jackson.map.annotate.JsonDeserialize; | ||
import org.codehaus.jackson.map.annotate.JsonSerialize; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* List of warehouses. Deserialization only. | ||
* List of warehouses. | ||
*/ | ||
@JsonDeserialize(using = WarehousesDeserializer.class) | ||
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) | ||
@JsonTypeName("instances") | ||
@JsonTypeName(Warehouses.ROOT_NODE) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Warehouses { | ||
@JsonSerialize(using = WarehousesSerializer.class) | ||
public class Warehouses extends PageableList<Warehouse> { | ||
|
||
static final String URI = "/gdc/datawarehouse/instances"; | ||
public static final String URI = "/gdc/datawarehouse/instances"; | ||
|
||
private final List<Warehouse> items; | ||
static final String ROOT_NODE = "instances"; | ||
|
||
@JsonCreator | ||
private Warehouses(@JsonProperty("items") List<Warehouse> items) { | ||
this.items = items; | ||
public Warehouses(final List<Warehouse> items, final Paging paging) { | ||
super(items, paging); | ||
} | ||
|
||
List<Warehouse> getItems() { | ||
return items; | ||
public Warehouses(final List<Warehouse> items, final Paging paging, final Map<String, String> links) { | ||
super(items, paging, links); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/gooddata/warehouse/WarehousesDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (C) 2007-2015, GoodData(R) Corporation. All rights reserved. | ||
*/ | ||
package com.gooddata.warehouse; | ||
|
||
import com.gooddata.collections.PageableListDeserializer; | ||
import com.gooddata.collections.Paging; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
class WarehousesDeserializer extends PageableListDeserializer<Warehouses, Warehouse> { | ||
|
||
protected WarehousesDeserializer() { | ||
super(Warehouse.class); | ||
} | ||
|
||
@Override | ||
protected Warehouses createList(final List<Warehouse> items, final Paging paging, final Map<String, String> links) { | ||
return new Warehouses(items, paging, links); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/gooddata/warehouse/WarehousesSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (C) 2007-2015, GoodData(R) Corporation. All rights reserved. | ||
*/ | ||
package com.gooddata.warehouse; | ||
|
||
import com.gooddata.collections.PageableListSerializer; | ||
|
||
import static com.gooddata.warehouse.Warehouses.ROOT_NODE; | ||
|
||
/** | ||
* Serializer of Warehouses object into JSON. | ||
*/ | ||
class WarehousesSerializer extends PageableListSerializer { | ||
|
||
public WarehousesSerializer() { | ||
super(ROOT_NODE); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.