Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset #8

Merged
merged 7 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.inqwise.opinion.infrastructure.dao.IResultSetCallback;
import com.inqwise.opinion.infrastructure.systemFramework.ApplicationLog;
import com.inqwise.opinion.infrastructure.systemFramework.Convert;
import com.inqwise.opinion.infrastructure.systemFramework.GeoIpManager;
import com.inqwise.opinion.library.common.IProduct;
import com.inqwise.opinion.library.common.ISession;
import com.inqwise.opinion.library.common.accounts.IAccount;
Expand All @@ -47,7 +48,6 @@
import com.inqwise.opinion.library.managers.ServicePackagesManager;
import com.inqwise.opinion.library.managers.UsersManager;
import com.inqwise.opinion.library.systemFramework.ApplicationConfiguration;
import com.inqwise.opinion.library.systemFramework.GeoIpManager;

public class ExternalLoginAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import net.casper.data.model.CDataCacheContainer;
import net.casper.data.model.CDataCacheDBAdapter;
import org.jooq.impl.DSL;
import org.json.JSONArray;
import org.json.JSONObject;

import com.inqwise.opinion.infrastructure.dao.DAOException;
import com.inqwise.opinion.infrastructure.dao.DAOUtil;
Expand All @@ -31,7 +28,7 @@ public class AccountsOperationsDataAccess {
private static final String MONETARY_TRANSACTION_PARAM = "$is_monetary";
private static final String ACCOUNT_OPERATION_ID_PARAM = "$accop_id";

public static CDataCacheContainer getAccountOperations(int top, long accountId, List<Integer> accountsOperationsTypeIds, Long referenceId, Integer referenceTypeId, Date fromDate, Date toDate, Boolean monetary) throws DAOException{
public static JSONArray getAccountOperations(int top, long accountId, List<Integer> accountsOperationsTypeIds, Long referenceId, Integer referenceTypeId, Date fromDate, Date toDate, Boolean monetary) throws DAOException{
Connection connection = null;
CallableStatement call = null;
ResultSet resultSet = null;
Expand All @@ -52,8 +49,18 @@ public static CDataCacheContainer getAccountOperations(int top, long accountId,
call = factory.GetProcedureCall("getAccountOperations", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = new String[]{"accop_id"};
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;

import net.casper.data.model.CDataCacheContainer;
import net.casper.data.model.CDataCacheDBAdapter;

import org.apache.commons.lang3.StringUtils;
import org.jooq.impl.DSL;
import org.json.JSONArray;
import org.json.JSONObject;

import com.inqwise.opinion.infrastructure.dao.DAOException;
import com.inqwise.opinion.infrastructure.dao.DAOUtil;
Expand Down Expand Up @@ -60,7 +58,7 @@ public class ChargesDataAccess {
private static final String POST_PAY_ACTION_DATA_PARAM = "$post_pay_action_data";


public static CDataCacheContainer getCharges(int top, Long billId, Integer billTypeId, Long accountId, Integer statusId, boolean includeExpired, Boolean billed) throws DAOException{
public static JSONArray getCharges(int top, Long billId, Integer billTypeId, Long accountId, Integer statusId, boolean includeExpired, Boolean billed) throws DAOException{
Connection connection = null;
CallableStatement call = null;
ResultSet resultSet = null;
Expand All @@ -80,8 +78,18 @@ public static CDataCacheContainer getCharges(int top, Long billId, Integer billT
call = factory.GetProcedureCall("pay_getCharges", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = new String[]{"charge_id"};
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new Hashtable());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down Expand Up @@ -218,7 +226,7 @@ public static void insertCharge(IChargeCreateRequest request,
}
}

public static CDataCacheContainer getPostPayActions(Long chargeId, Long billId, Integer billTypeId) throws DAOException{
public static JSONArray getPostPayActions(Long chargeId, Long billId, Integer billTypeId) throws DAOException{
Connection connection = null;
CallableStatement call = null;
ResultSet resultSet = null;
Expand All @@ -234,8 +242,18 @@ public static CDataCacheContainer getPostPayActions(Long chargeId, Long billId,
call = factory.GetProcedureCall("pay_getBillPostPayActions", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = new String[] {"charge_id"};
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down Expand Up @@ -296,7 +314,7 @@ public static OperationResult<ChargeStatus> pay(IChargePayRequest request) throw
}
}

public static CDataCacheContainer getChargesByReferenceId(Long accountId,
public static JSONArray getChargesByReferenceId(Long accountId,
long referenceId, int referenceTypeId) throws DAOException {
Connection connection = null;
CallableStatement call = null;
Expand All @@ -313,8 +331,18 @@ public static CDataCacheContainer getChargesByReferenceId(Long accountId,
call = factory.GetProcedureCall("pay_getChargeByReferenceId", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = null;
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.LinkedHashMap;
import java.util.List;

import net.casper.data.model.CDataCacheContainer;
import net.casper.data.model.CDataCacheDBAdapter;
import org.jooq.impl.DSL;
import org.json.JSONArray;
import org.json.JSONObject;

import com.inqwise.opinion.infrastructure.dao.DAOException;
import com.inqwise.opinion.infrastructure.dao.DAOUtil;
Expand Down Expand Up @@ -137,7 +138,7 @@ public static void getInviteResultSet(Long inviteId, Long accountId,
}
}

public static CDataCacheContainer getInvites(long accountId) throws DAOException {
public static JSONArray getInvites(long accountId) throws DAOException {
Connection connection = null;
CallableStatement call = null;
ResultSet resultSet = null;
Expand All @@ -151,8 +152,19 @@ public static CDataCacheContainer getInvites(long accountId) throws DAOException
call = factory.GetProcedureCall("invites_getInvites", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = null;
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;

import net.casper.data.model.CDataCacheContainer;
import net.casper.data.model.CDataCacheDBAdapter;
import org.jooq.impl.DSL;
import org.json.JSONArray;
import org.json.JSONObject;

import com.inqwise.opinion.infrastructure.dao.DAOException;
import com.inqwise.opinion.infrastructure.dao.DAOUtil;
Expand All @@ -26,13 +23,11 @@
import com.inqwise.opinion.library.common.errorHandle.BaseOperationResult;
import com.inqwise.opinion.library.common.errorHandle.ErrorCode;
import com.inqwise.opinion.library.common.errorHandle.OperationResult;
import com.inqwise.opinion.library.common.pay.BillType;
import com.inqwise.opinion.library.common.pay.ChargeStatus;
import com.inqwise.opinion.library.common.pay.IInvoiceCreateRequest;
import com.inqwise.opinion.library.common.pay.IOpenInvoiceRequest;
import com.inqwise.opinion.library.common.pay.IUpdateInvoiceRequest;
import com.inqwise.opinion.library.common.pay.InvoiceItemType;
import com.inqwise.opinion.library.common.pay.InvoiceStatus;

public class InvoicesDataAccess {

Expand Down Expand Up @@ -162,7 +157,7 @@ public static boolean deleteInvoice(long invoiceId, long userId) throws DAOExcep
}
}

public static CDataCacheContainer getInvoices(int top, Long accountId,
public static JSONArray getInvoices(int top, Long accountId,
Integer invoiceStatusId) throws DAOException {
Connection connection = null;
CallableStatement call = null;
Expand All @@ -179,8 +174,18 @@ public static CDataCacheContainer getInvoices(int top, Long accountId,
call = factory.GetProcedureCall("pay_getInvoices", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = new String[]{"invoice_id"};
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down Expand Up @@ -285,7 +290,7 @@ public static BaseOperationResult openInvoice(IOpenInvoiceRequest request) throw
}
}

public static Map<InvoiceItemType, CDataCacheContainer> getInvoiceItems(long billId, int billTypeId) throws DAOException {
public static Map<InvoiceItemType, JSONArray> getInvoiceItems(long billId, int billTypeId) throws DAOException {
Connection connection = null;
CallableStatement call = null;
ResultSet resultSet = null;
Expand All @@ -300,16 +305,15 @@ public static Map<InvoiceItemType, CDataCacheContainer> getInvoiceItems(long bil
call = factory.GetProcedureCall("pay_getBillItems", params);
connection = call.getConnection();

Map<InvoiceItemType, CDataCacheContainer> result = new HashMap<InvoiceItemType, CDataCacheContainer>();
Map<InvoiceItemType, JSONArray> result = new HashMap<InvoiceItemType, JSONArray>();

resultSet = call.executeQuery();
String[] primaryKeys = null;
result.put(InvoiceItemType.Charge, CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap()));
resultSet = call.executeQuery();
result.put(InvoiceItemType.Charge, resultsetToJson(connection, resultSet));

if(call.getMoreResults()){
resultSet.close();
resultSet = call.getResultSet();
result.put(InvoiceItemType.AccountOperation, CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap()));
resultSet = call.getResultSet();
result.put(InvoiceItemType.AccountOperation, resultsetToJson(connection, resultSet));
}

return result;
Expand All @@ -321,4 +325,18 @@ public static Map<InvoiceItemType, CDataCacheContainer> getInvoiceItems(long bil
DAOUtil.close(connection);
}
}

private static JSONArray resultsetToJson(Connection connection, ResultSet resultSet) {
List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Date;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;

import net.casper.data.model.CDataCacheContainer;
import net.casper.data.model.CDataCacheDBAdapter;
import org.jooq.impl.DSL;
import org.json.JSONArray;
import org.json.JSONObject;

import com.inqwise.opinion.infrastructure.dao.DAOException;
import com.inqwise.opinion.infrastructure.dao.DAOUtil;
Expand Down Expand Up @@ -167,7 +167,7 @@ public static void updateMessage(long messageId, String messageName,
}
}

public static CDataCacheContainer getMessages(Long userId,
public static JSONArray getMessages(Long userId,
Date fromModifyDate, Date toModifyDate, boolean includeClosed,
boolean includeNotActivated, int top, boolean includeExcluded) throws DAOException {
Connection connection = null;
Expand All @@ -189,8 +189,18 @@ public static CDataCacheContainer getMessages(Long userId,
call = factory.GetProcedureCall("msg_getMessages", params);
connection = call.getConnection();
resultSet = call.executeQuery();
String[] primaryKeys = null;
return CDataCacheDBAdapter.loadData(resultSet, null, primaryKeys, new LinkedHashMap());

List<JSONObject> list = DSL.using(connection).fetch(resultSet)
.map(r -> {
JSONObject obj = new JSONObject();

for(var field : r.fields()) {
obj.put(field.getName(), r.getValue(field));
}
return obj;
});

return new JSONArray(list);

} catch (Exception e) {
throw null == call ? new DAOException(e) : new DAOException(call, e);
Expand Down
Loading
Loading