Search in sources :

Example 6 with UserInformation

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();
}
Also used : ModelContext(com.genexus.ModelContext) JSONArray(json.org.json.JSONArray) UserInformation(com.genexus.db.UserInformation) Method(java.lang.reflect.Method)

Example 7 with UserInformation

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);
    }
}
Also used : UserInformation(com.genexus.db.UserInformation)

Example 8 with UserInformation

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);
    }
}
Also used : UserInformation(com.genexus.db.UserInformation)

Aggregations

UserInformation (com.genexus.db.UserInformation)8 SQLException (java.sql.SQLException)5 ModelContext (com.genexus.ModelContext)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 JSONArray (json.org.json.JSONArray)1