Java Code Examples for com.mongodb.BasicDBObject#copy()
The following examples show how to use
com.mongodb.BasicDBObject#copy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserResource.java From XBDD with Apache License 2.0 | 6 votes |
@PUT @Path("/ignoredTags/{product}") @Consumes(MediaType.APPLICATION_JSON) public Response putIgnoredTags(@BeanParam final Coordinates coordinates, final BasicDBObject patch) { final DBCollection collection = this.mongoLegacyDb.getCollection("ignoredTags"); final BasicDBObject coq = coordinates.getProductCoordinatesQueryObject(); final BasicDBObject storedDocument = (BasicDBObject) collection.findOne(coq); final String tagName = (String) patch.get("tagName"); if (storedDocument != null) { final BasicDBObject documentToUpdate = (BasicDBObject) storedDocument.copy(); updateIgnoredTag(documentToUpdate, tagName); collection.save(documentToUpdate); } else { final DBObject newDocument = generateNewIgnoredTags(coordinates, tagName); collection.save(newDocument); } return Response.ok().build(); }
Example 2
Source File: Feature.java From XBDD with Apache License 2.0 | 5 votes |
@PUT @Path("/comments/{product}/{major}.{minor}.{servicePack}/{build}/{featureId:.+}") @Consumes(MediaType.APPLICATION_JSON) public Response updateCommentWithPatch(@BeanParam final Coordinates coordinates, @PathParam("featureId") final String featureId, final BasicDBObject patch) { try { final DBCollection collection = this.mongoLegacyDb.getCollection("features"); final BasicDBObject example = coordinates.getReportCoordinatesQueryObject().append("id", featureId); final BasicDBObject storedFeature = (BasicDBObject) collection.findOne(example); final String scenarioId = (String) patch.get("scenarioId"); final String label = (String) patch.get("label"); final String content = (String) patch.get("content"); final BasicDBObject featureToUpdate = (BasicDBObject) storedFeature.copy(); final BasicDBObject scenarioToUpdate = getScenarioById(scenarioId, featureToUpdate); scenarioToUpdate.put(label, content); if (label.equals("testing-tips")) { final DBCollection tips = this.mongoLegacyDb.getCollection("testingTips"); updateTestingTipsForScenario(tips, scenarioToUpdate, coordinates, featureId); } featureToUpdate.put("statusLastEditedBy", LoggedInUserUtil.getLoggedInUser().getDisplay()); featureToUpdate.put("lastEditOn", new Date()); featureToUpdate.put("calculatedStatus", calculateStatusForFeature(featureToUpdate)); collection.save(featureToUpdate); if (label.equals("testing-tips")) { Feature.embedTestingTips(featureToUpdate, coordinates, this.mongoLegacyDb); } return Response.ok().build(); } catch (final Throwable th) { th.printStackTrace(); return Response.serverError().build(); } }
Example 3
Source File: Feature.java From XBDD with Apache License 2.0 | 5 votes |
@PUT @Path("/step/{product}/{major}.{minor}.{servicePack}/{build}/{featureId:.+}") @Consumes(MediaType.APPLICATION_JSON) public Response updateStepWithPatch(@BeanParam final Coordinates coordinates, @PathParam("featureId") final String featureId, final BasicDBObject patch) { try { final DBCollection collection = this.mongoLegacyDb.getCollection("features"); final BasicDBObject example = coordinates.getReportCoordinatesQueryObject().append("id", featureId); final BasicDBObject storedFeature = (BasicDBObject) collection.findOne(example); final int stepLine = (int) patch.get("line"); final String status = (String) patch.get("status"); final String scenarioId = (String) patch.get("scenarioId"); final BasicDBObject featureToUpdate = (BasicDBObject) storedFeature.copy(); final BasicDBObject scenarioToUpdate = getScenarioById(scenarioId, featureToUpdate); boolean found = false; if (scenarioToUpdate.get("background") != null) { final BasicDBObject backgroundToUpdate = (BasicDBObject) (scenarioToUpdate.get("background")); final BasicDBList backgroundStepsToUpdate = (BasicDBList) (backgroundToUpdate.get("steps")); found = updateSteps(backgroundStepsToUpdate, stepLine, status); } if (!found) { final BasicDBList stepsToUpdate = (BasicDBList) (scenarioToUpdate.get("steps")); updateSteps(stepsToUpdate, stepLine, status); } featureToUpdate.put("statusLastEditedBy", LoggedInUserUtil.getLoggedInUser().getDisplay()); featureToUpdate.put("lastEditOn", new Date()); featureToUpdate.put("calculatedStatus", calculateStatusForFeature(featureToUpdate)); collection.save(featureToUpdate); return Response.ok().build(); } catch (final Throwable th) { th.printStackTrace(); return Response.serverError().build(); } }
Example 4
Source File: Feature.java From XBDD with Apache License 2.0 | 5 votes |
@PUT @Path("/steps/{product}/{major}.{minor}.{servicePack}/{build}/{featureId:.+}") @Consumes(MediaType.APPLICATION_JSON) public Response updateStepsWithPatch(@BeanParam final Coordinates coordinates, @PathParam("featureId") final String featureId, final BasicDBObject patch) { try { final DBCollection collection = this.mongoLegacyDb.getCollection("features"); final BasicDBObject example = coordinates.getReportCoordinatesQueryObject().append("id", featureId); final BasicDBObject storedFeature = (BasicDBObject) collection.findOne(example); final String status = (String) patch.get("status"); final String scenarioId = (String) patch.get("scenarioId"); final BasicDBObject featureToUpdate = (BasicDBObject) storedFeature.copy(); final BasicDBObject scenarioToUpdate = getScenarioById(scenarioId, featureToUpdate); if (scenarioToUpdate.get("background") != null) { final BasicDBObject backgroundToUpdate = (BasicDBObject) (scenarioToUpdate.get("background")); final BasicDBList backgroundStepsToUpdate = (BasicDBList) (backgroundToUpdate.get("steps")); updateAllSteps(backgroundStepsToUpdate, status); } if (scenarioToUpdate.get("steps") != null) { final BasicDBList stepsToUpdate = (BasicDBList) (scenarioToUpdate.get("steps")); updateAllSteps(stepsToUpdate, status); } featureToUpdate.put("statusLastEditedBy", LoggedInUserUtil.getLoggedInUser().getDisplay()); featureToUpdate.put("lastEditOn", new Date()); featureToUpdate.put("calculatedStatus", calculateStatusForFeature(featureToUpdate)); collection.save(featureToUpdate); return Response.ok().build(); } catch (final Throwable th) { th.printStackTrace(); return Response.serverError().build(); } }