-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use java command wrappers and params to create plates (#1864)
- Loading branch information
1 parent
a02b4da
commit 26d6f11
Showing
3 changed files
with
163 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.labkey.remoteapi.plate; | ||
|
||
import org.json.JSONObject; | ||
import org.labkey.remoteapi.PostCommand; | ||
|
||
public class CreatePlateSetCommand extends PostCommand<PlateSetResponse> | ||
{ | ||
private final PlateSetParams _plateSetParams; | ||
public CreatePlateSetCommand(PlateSetParams params) | ||
{ | ||
super("plate", "createPlateSet"); | ||
setRequiredVersion(0); | ||
_plateSetParams = params; | ||
} | ||
|
||
@Override | ||
protected PlateSetResponse createResponse(String text, int status, String contentType, JSONObject json) | ||
{ | ||
return new PlateSetResponse(text, status, contentType, json); | ||
} | ||
|
||
@Override | ||
public JSONObject getJsonObject() | ||
{ | ||
return _plateSetParams.toJSON(); | ||
} | ||
} |
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,116 @@ | ||
package org.labkey.remoteapi.plate; | ||
|
||
|
||
import org.json.JSONObject; | ||
|
||
public class PlateSetParams | ||
{ | ||
private String _name = null; | ||
private String _description = null; | ||
private PlateSetType _type = null; | ||
private Integer _id = null; | ||
private Integer _parentPlateSetId = null; | ||
|
||
public PlateSetParams() | ||
{ | ||
} | ||
|
||
public PlateSetParams(JSONObject json) | ||
{ | ||
_name = json.getString("name"); | ||
_description = json.optString("description", null); | ||
_type = PlateSetType.fromName(json.optString("type", null)); | ||
_id = json.getInt("rowId"); | ||
_parentPlateSetId = json.optIntegerObject("parentPlateSetId", null); | ||
} | ||
|
||
public JSONObject toJSON() | ||
{ | ||
JSONObject json = new JSONObject(); | ||
json.put("name", _name); | ||
json.put("description", _description); | ||
if (_type != null) | ||
json.put("type", _type.getType()); | ||
json.put("rowId", _id); | ||
json.put("parentPlateSetId", _parentPlateSetId); | ||
return json; | ||
} | ||
|
||
public PlateSetParams setName(String name) | ||
{ | ||
_name = name; | ||
return this; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return _name; | ||
} | ||
|
||
public PlateSetParams setDescription(String description) | ||
{ | ||
_description = description; | ||
return this; | ||
} | ||
|
||
public String getDescription() | ||
{ | ||
return _description; | ||
} | ||
|
||
public PlateSetParams setType(PlateSetType type) | ||
{ | ||
_type = type; | ||
return this; | ||
} | ||
|
||
public PlateSetType getType() | ||
{ | ||
return _type; | ||
} | ||
|
||
public Integer getId() | ||
{ | ||
return _id; | ||
} | ||
|
||
public PlateSetParams setParentPlateSetId(Integer parentPlateSetId) | ||
{ | ||
_parentPlateSetId = parentPlateSetId; | ||
return this; | ||
} | ||
|
||
public Integer getParentPlateSetId() | ||
{ | ||
return _parentPlateSetId; | ||
} | ||
|
||
|
||
public enum PlateSetType | ||
{ | ||
Primary("primary"), | ||
Assay("assay"); | ||
|
||
PlateSetType(String type) | ||
{ | ||
this._type = type; | ||
} | ||
private final String _type; | ||
public String getType() | ||
{ | ||
return _type; | ||
} | ||
public static PlateSetType fromName(String type) | ||
{ | ||
if (type != null) | ||
{ | ||
for (PlateSetType plateSetType : PlateSetType.values()) | ||
{ | ||
if (type.equalsIgnoreCase(plateSetType.getType())) | ||
return plateSetType; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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,20 @@ | ||
package org.labkey.remoteapi.plate; | ||
|
||
import org.json.JSONObject; | ||
import org.labkey.remoteapi.CommandResponse; | ||
|
||
public class PlateSetResponse extends CommandResponse | ||
{ | ||
private final PlateSetParams _plateSetParams; | ||
|
||
public PlateSetResponse(String text, int statusCode, String contentType, JSONObject json) | ||
{ | ||
super(text, statusCode, contentType, json); | ||
_plateSetParams = new PlateSetParams(json.getJSONObject("data")); | ||
} | ||
|
||
public PlateSetParams getPlateSetParams() | ||
{ | ||
return _plateSetParams; | ||
} | ||
} |