/** * Remove a Warp from the data source * * @param warp Warp instance to remove from the data source. */ public void removeWarp(Warp warp) { try { HashMap<String, Object> filter = new HashMap<String, Object>(); filter.put("name", warp.getName()); // filter.put("location", warp.getLocation().toString()); // Location is a bad filter, mkay Database.get().remove(schema, filter); } catch (DatabaseWriteException e) { log.error(e.getMessage(), e); } }
/** * Update a Warp * * @param warp Warp instance to update to the data source. */ public void updateWarp(Warp warp) { WarpDataAccess data = schema.getInstance(); data.groups = warp.getGroupsAsString(); data.isPlayerHome = warp.isPlayerHome(); // data.location = warp.getLocation().toString(); Deprecated data.location = "N/A"; warp.getLocation().toDataAccess(data); // Replacing data.location data.name = warp.getName(); data.owner = warp.getOwner(); try { HashMap<String, Object> filter = new HashMap<String, Object>(); filter.put("name", warp.getName()); Database.get().update(data, filter); } catch (DatabaseWriteException e) { log.error(e.getMessage(), e); } }
/** * Add a new Warp to the list of Warps. * * @param warp Warp instance to add to the data source. */ public void addWarp(Warp warp) { if (warpExists(warp)) { updateWarp(warp); return; } WarpDataAccess data = schema.getInstance(); data.groups = warp.getGroupsAsString(); data.isPlayerHome = warp.isPlayerHome(); // data.location = warp.getLocation().toString(); deprecated data.location = "N/A"; warp.getLocation().toDataAccess(data); // Replacing data.location data.name = warp.getName(); data.owner = warp.getOwner(); try { Database.get().insert(data); } catch (DatabaseWriteException e) { log.error(e.getMessage(), e); } }