Following a builder pattern a bit like EntityQuery:

ServiceResult createProductResult = ServiceContext.create(dispatcher,
userLogin)
        .add("brandName", brandName)
        .add("productName", productName)
        .add("longDescription", description)
        .add("internalName", internalName)
        .add("introductionDate", UtilDateTime.nowTimestamp())
        .add("productTypeId", "FINISHED_GOOD")
        .newTransaction()
        .runSync("createProduct");
if (createProductResult.isError()) {
    return ServiceUtil.returnError("Could not create Product: " +
createProductResult.getErrorMessage());
}
productId = createProductResult.getString("productId");


Calling a service from java always seems so cumbersome to me, maybe
something like the above would make it a little bit nicer?

Regards
Scott

Reply via email to