/** * Queries for <tt>CapitalMarketsOrder</tt> with the provided <tt>scope</tt> in the background. * * <p>Note: the scopes were defined from the Designer. * * <p>The {@link import com.anypresence.sdk.callbacks.APCallback} callback allows you to run code * in the main UI thread. * * <p>Example: * * <pre>{@code * Map<String,String> params = new HashMap<String,String>(); * params.put("name", "test"); * CapitalMarketsOrder.queryInBackground("all", params, 0, 25, new APCallback<List<CapitalMarketsOrder>>() { * * public void finished(List<CapitalMarketsOrder> objects, Throwable ex) { * if (ex == null) { * Log.i(TAG, "Objects fetched!"); * } else { * Log.e(TAG, "Unable to fetch objects!", ex); * } * } * }); * }</pre> * * @see import com.anypresence.sdk.callbacks.APCallback * @param scope the scope to perform the query. * @param params a map of parameters. * @param offset offset for the query, or <tt>null</tt> for no offset. * @param limit max results to return back, <tt>null</tt> for no limit. * @param futureCallback the callback that handles the result of the request. */ public static List<CapitalMarketsOrder> queryInBackground( final String scope, Map<String, String> params, Integer offset, Integer limit, IAPFutureCallback<List<CapitalMarketsOrder>> futureCallback) { RemoteRequest.RemoteRequestBuilder remoteRequestBuilder = RemoteRailsConfig.getRouterAdapterByClassOrUseDefaultAdapter(CapitalMarketsOrder.class) .createRemoteRequestBuilder(scope, RequestMethod.GET, CapitalMarketsOrder.class); remoteRequestBuilder.query(scope); if (params != null) { remoteRequestBuilder.addToParameters(params); remoteRequestBuilder.context(params); } if (offset != null) { remoteRequestBuilder.addToParameters("offset", offset.toString()); } if (limit != null) { remoteRequestBuilder.addToParameters("limit", limit.toString()); } RemoteRequest remoteRequest = remoteRequestBuilder.createRemoteRequest(); if (DEBUG_MODE) { System.out.println(ReflectionToStringBuilder.reflectionToString(remoteRequest)); } return com.anypresence.sdk.APObject.queryInBackground( remoteRequest, CapitalMarketsOrder.class, futureCallback); }
/** * Fetches a <tt>CapitalMarketsOrder</tt> with the provided <tt>objectId</tt>. * * @param objectId the id of the object * @return an instance of <tt>CapitalMarketsOrder</tt> * @throws RemoteRequestException If there are other issues with the request. */ public static CapitalMarketsOrder fetch(String objectId) throws RemoteRequestException { RemoteRequest.RemoteRequestBuilder remoteRequestBuilder = RemoteRailsConfig.getRouterAdapterByClassOrUseDefaultAdapter(CapitalMarketsOrder.class) .createRemoteRequestBuilder(RequestMethod.GET, CapitalMarketsOrder.class); CapitalMarketsOrder object = new CapitalMarketsOrder(); object.setObjectIdAsString(objectId); remoteRequestBuilder.context(object); RemoteRequest remoteRequest = remoteRequestBuilder.createRemoteRequest(); remoteRequest = Utility.interpolateRemoteRequest(remoteRequest); return com.anypresence.sdk.APObject.fetch(remoteRequest, CapitalMarketsOrder.class); }
@Test public void shouldBeAbleDeleteFromCache() throws com.anypresence.sdk.acl.UnauthorizedException, RemoteRequestException, InterruptedException, ClassNotFoundException { APSetup.setBaseUrl("http://localhost"); APSetup.setup(); Config.getInstance().setStrictQueryFieldCheck(false); APSDKSetup.setDBStoreType(DBStoreType.IN_MEMORY); Config.DEBUG_MODE = true; RemoteRailsConfig.getInstance().setInlineMode(true); lock = new CountDownLatch(1); IRestClient client = getTestRestClient(); RestClientFactory.registerJSONRestClientImplementation(client); com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.queryInBackground( "all", null, new APFutureCallback< List<com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin>>() { @Override public void finished( List<com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin> arg0, Throwable ex) { objects = arg0; lock.countDown(); } }); lock.await(); Assert.assertTrue(objects.size() == 2); // Delete one object in cache objects.get(0).deleteInCache(); Assert.assertTrue( com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.loadAllInCache().size() == 1); // Delete all objects in the cache com.anypresence.sdk.APObject.deleteAllInCache(); Assert.assertTrue( com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.loadAllInCache().size() == 0); }
/** * Queries for <tt>CapitalMarketsOrder</tt> with the provided <tt>scope</tt> and other params. * * <p>Note: the scopes were defined from the Designer. * * @param scope the scope to perform the query. * @param params a map of parameters. * @param offset offset for the query, or <tt>null</tt> for no offset. * @param limit max results to return back, <tt>null</tt> for no limit. * @throws RemoteRequestException If there are other issues with the request. */ public static List<CapitalMarketsOrder> query( String scope, Map<String, String> params, Integer offset, Integer limit) throws RemoteRequestException { RemoteRequest.RemoteRequestBuilder remoteRequestBuilder = RemoteRailsConfig.getRouterAdapterByClassOrUseDefaultAdapter(CapitalMarketsOrder.class) .createRemoteRequestBuilder(scope, RequestMethod.GET, CapitalMarketsOrder.class); remoteRequestBuilder.query(scope); if (params != null) { remoteRequestBuilder.addToParameters(params); remoteRequestBuilder.context(params); } if (offset != null) { remoteRequestBuilder.addToParameters("offset", offset.toString()); } if (limit != null) { remoteRequestBuilder.addToParameters("limit", limit.toString()); } RemoteRequest remoteRequest = remoteRequestBuilder.createRemoteRequest(); return com.anypresence.sdk.APObject.query( remoteRequest, offset, limit, CapitalMarketsOrder.class); }
/** Deletes all data in cache for <tt>CapitalMarketsOrder</tt>. */ public static void deleteAllInCache() { com.anypresence.sdk.APObject.deleteAllInCache(); }
/** * Performs aggregate query with the provided <tt>scope</tt> in the background. * * <p>Note: the scopes were defined from the Designer. * * <p>The {@link import com.anypresence.sdk.callbacks.APCallback} callback allows you to run code * in the main UI thread. * * <p>Example: * * <pre>{@code * Map<String,String> params = new HashMap<String,String>(); * CapitalMarketsOrder.aggregateQueryInBackground("count", params, new APCallback<String>() { * * public void finished(String count, Throwable ex) { * if (ex == null) { * Log.i(TAG, "success"); * } else { * Log.e(TAG, "failure", ex); * } * } * }); * }</pre> * * @see import com.anypresence.sdk.callbacks.APCallback * @param scope the scope to perform the query. * @param params a map of parameters. * @param futureCallback the callback that handles the result of the request. */ public static void aggregateQueryInBackground( String scope, Map<String, String> params, IAPFutureCallback<String> futureCallback) { com.anypresence.sdk.APObject.aggregateQueryInBackground( scope, params, CapitalMarketsOrder.class, futureCallback); }
/** * Performs aggregate query with the provided <tt>scope</tt>. * * <p>Note: the scopes were defined from the Designer. * * @param scope the scope to perform the query. * @param params a map of parameters. * @throws RemoteRequestException If there are other issues with the request. */ public static String aggregateQuery(String scope, Map<String, String> params) throws RemoteRequestException { return com.anypresence.sdk.APObject.aggregateQuery(scope, params, CapitalMarketsOrder.class); }
/** * Fetches a <tt>CapitalMarketsOrder</tt> with the provided <tt>objectId</tt> in the background. * * <p>The {@link import com.anypresence.sdk.callbacks.APCallback} callback allows you to run code * in the main UI thread. * * <p>Example: * * <pre>{@code * CapitalMarketsOrder.fetchInBackground("123", new APCallback<CapitalMarketsOrder>() { * * public void finished(CapitalMarketsOrder object, Throwable ex) { * if (ex == null) { * Log.i(TAG, "Object fetched!"); * } else { * Log.e(TAG, "Unable to fetch object!", ex); * } * } * }); * }</pre> * * @see import com.anypresence.sdk.callbacks.APCallback * @param objectId the id of the object * @param futureCallback the callback that handles the result of the request. * @return the cached <tt>CapitalMarketsOrder</tt> if it exists, otherwise, null. */ public static CapitalMarketsOrder fetchInBackground( String objectId, IAPFutureCallback<CapitalMarketsOrder> futureCallback) { return com.anypresence.sdk.APObject.fetchInBackground( objectId, CapitalMarketsOrder.class, futureCallback); }