public void transferMoney(Long sourceAccountId, Long targetAccountId, BigDecimal amount) { Account source = accountDAO.getById(sourceAccountId); Account target = accountDAO.getById(targetAccountId); if (source.getBalance().compareTo(amount) < 0) { throw new NotEnoughMoneyException(); } source.decrementBalance(amount); target.incrementBalance(amount); auditDAO.insertTransaction(sourceAccountId, targetAccountId, amount); // other business logic }
var model = new Goal({id: 123}); model.fetch(); console.log(model.toJSON());
@Override public String getEntryRequestVerb(Bundle.BundleEntryComponent theEntry) { String retVal = null; Bundle.HTTPVerb value = theEntry.getRequest().getMethodElement().getValue(); if (value != null) { retVal = value.toCode(); } return retVal; }
protected String addReference(DomainResource r, String title, String id) throws Exception { if (r.getText() == null) r.setText(new Narrative()); if (r.getText().getDiv() == null) { r.getText().setStatus(NarrativeStatus.GENERATED); new NarrativeGenerator("", "", context).generate(r); } r.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); r.setId(id); feed.getEntry().add(new BundleEntryComponent().setResource(r)); return id; }
private void addConcepts(ConceptSetComponent theInclude, ValueSetExpansionComponent theRetVal, Set<String> theWantCodes, List<ConceptDefinitionComponent> theConcepts) { for (ConceptDefinitionComponent next : theConcepts) { if (theWantCodes.isEmpty() || theWantCodes.contains(next.getCode())) { theRetVal .addContains() .setSystem(theInclude.getSystem()) .setCode(next.getCode()) .setDisplay(next.getDisplay()); } addConcepts(theInclude, theRetVal, theWantCodes, next.getConcept()); } }
public void foo() { //START SNIPPET: subExtension Patient patient = new Patient(); // Add an extension (initially with no contents) to the resource Extension parent = new Extension("http://example.com#parent"); patient.addExtension(parent); // Add two extensions as children to the parent extension Extension child1 = new Extension("http://example.com#childOne", new StringType("value1")); parent.addExtension(child1); Extension child2 = new Extension("http://example.com#chilwo", new StringType("value1")); parent.addExtension(child2); //END SNIPPET: subExtension }
@Override public void populateEntryWithOperationOutcome(BaseServerResponseException theCaughtEx, Bundle.BundleEntryComponent theEntry) { OperationOutcome oo = new OperationOutcome(); oo.addIssue().setSeverity(OperationOutcome.IssueSeverity.ERROR).setDiagnostics(theCaughtEx.getMessage()); theEntry.getResponse().setOutcome(oo); }
private String describeReference(Type reference) { if (reference == null) return "null"; if (reference instanceof UriType) return ((UriType) reference).getValue(); if (reference instanceof Reference) return ((Reference) reference).getReference(); return "??"; }
@Override public String getBundleType(Bundle theRequest) { if (theRequest.getType() == null) { return null; } return theRequest.getTypeElement().getValue().toCode(); }
@Override public void setRequestVerb(Bundle.BundleEntryComponent theEntry, String theVerb) { theEntry.getRequest().setMethod(Bundle.HTTPVerb.fromCode(theVerb)); }
private static <T extends Enum<?>> String extractSystem(Enumeration<T> theBoundCode) { if (theBoundCode.getValue() != null) { return theBoundCode.getEnumFactory().toSystem(theBoundCode.getValue()); } return null; }
protected ElementDefinition findElement(StructureDefinition profile, String name) { for (ElementDefinition c : profile.getSnapshot().getElement()) { if (c.getPath().equals(name)) { return c; } } return null; }
@Override public String getEntryRequestUrl(Bundle.BundleEntryComponent theEntry) { return theEntry.getRequest().getUrl(); }
protected ListEntryComponent addItemToList(ListResource list, DomainResource ai) throws Exception { list.getContained().add(ai); String n = nextRef(); ai.setId(n); ListEntryComponent item = new ListResource.ListEntryComponent(); list.getEntry().add(item); item.setItem(Factory.makeReference("#"+n)); return item; }
@Override public String getEntryRequestIfNoneMatch(Bundle.BundleEntryComponent theEntry) { return theEntry.getRequest().getIfNoneMatch(); }
@Override public void setResponseLastModified(Bundle.BundleEntryComponent theBundleEntry, Date theLastModified) { theBundleEntry.getResponse().setLastModified(theLastModified); }
@Override public void setResponseLocation(Bundle.BundleEntryComponent theEntry, String theResponseLocation) { theEntry.getResponse().setLocation(theResponseLocation); }
@Override public void setResponseETag(Bundle.BundleEntryComponent theEntry, String theEtag) { theEntry.getResponse().setEtag(theEtag); }
@Override public void setResponseOutcome(Bundle.BundleEntryComponent theEntry, IBaseOperationOutcome theOperationOutcome) { theEntry.getResponse().setOutcome((Resource) theOperationOutcome); }
output = new TestReport(); output.setDateFormat(Utils.getDateFormat(Utils.DATE_FORMAT_ENGLISH));