use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class GXMultiCall method gxMultiCall.
@javax.ws.rs.POST
@jakarta.ws.rs.POST
@javax.ws.rs.Consumes({ javax.ws.rs.core.MediaType.APPLICATION_JSON })
@jakarta.ws.rs.Consumes({ jakarta.ws.rs.core.MediaType.APPLICATION_JSON })
@javax.ws.rs.Produces({ javax.ws.rs.core.MediaType.APPLICATION_JSON + ";charset=UTF-8" })
@jakarta.ws.rs.Produces({ jakarta.ws.rs.core.MediaType.APPLICATION_JSON + ";charset=UTF-8" })
public Object gxMultiCall(String jsonStr) throws Exception {
super.init("POST");
String procName = ((HttpContextWeb) context.getHttpContext()).GetNextPar().toLowerCase();
ModelContext modelContext = ModelContext.getModelContext(Application.gxCfg);
String appPackage = modelContext.getNAME_SPACE();
if (!appPackage.equals("")) {
appPackage = appPackage + ".";
}
String restProcName = procName + "_services_rest";
try {
Class myClassRest = Class.forName(appPackage + restProcName);
} catch (ClassNotFoundException cnf) {
builder = Response.notFound();
cleanup();
return builder.build();
}
Class myClass = Class.forName(appPackage + procName);
Method[] methods = myClass.getMethods();
Class[] parameters = null;
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
if (method.getName().equalsIgnoreCase(METHOD_EXECUTE)) {
parameters = method.getParameterTypes();
}
}
int parmCount;
JSONArray jsonArr = new JSONArray(jsonStr);
UserInformation ui = Application.getConnectionManager().createUserInformation(Namespace.getNamespace(modelContext.getNAME_SPACE()));
int remoteHandle = ui.getHandle();
for (int i = 0; i < jsonArr.length(); i++) {
JSONArray procParms = new JSONArray(jsonArr.getJSONArray(i).toString());
parmCount = procParms.length();
Object[] params = new Object[parmCount];
for (int j = 0; j < parmCount; j++) {
params[j] = GXutil.convertObjectTo(procParms.getString(j), parameters[j]);
}
com.genexus.db.DynamicExecute.dynamicExecute(modelContext, remoteHandle, modelContext.packageClass, appPackage + procName, params);
}
Application.cleanupConnection(remoteHandle);
builder = Response.okWrapped();
builder.type("application/json");
builder.entity("");
cleanup();
return builder.build();
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method commitDataStores.
// Commit de todos los datastores usando la error_handler del datastore pasado por parametro.
public static void commitDataStores(ModelContext context, int remoteHandle, com.genexus.db.IDataStoreProvider dataStore, String objName) {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
for (Enumeration<com.genexus.db.driver.DataSource> en = info.getNamespace().getDataSources(); en.hasMoreElements(); ) {
String dataSourceName = en.nextElement().getName();
commit(context, remoteHandle, dataSourceName, dataStore, objName);
}
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method rollbackDataStores.
// Rollback de todos los datastores usando la error_handler del datastore pasado por parametro.
public static void rollbackDataStores(ModelContext context, int remoteHandle, com.genexus.db.IDataStoreProvider dataStore, String objName) {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
for (Enumeration<com.genexus.db.driver.DataSource> en = info.getNamespace().getDataSources(); en.hasMoreElements(); ) {
String dataSourceName = en.nextElement().getName();
rollback(context, remoteHandle, dataSourceName, dataStore, objName);
}
}
Aggregations