use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.FIELD in project carbon-apimgt by wso2.
the class EntityDAO method getLastUpdatedTimeOfResourceByUUID.
/**
* Returns the last access time of the given entity identified by the UUID field.
*
* @param resourceTableName Table name of the entity
* @param uuid value of the UUID field of the entity
* @return Last access time of the requested resource
* @throws APIMgtDAOException
*/
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING")
static String getLastUpdatedTimeOfResourceByUUID(String resourceTableName, String uuid) throws APIMgtDAOException {
final String query = "SELECT LAST_UPDATED_TIME FROM " + resourceTableName + " WHERE UUID = ?";
String lastUpdatedTime = null;
try (Connection connection = DAOUtil.getConnection();
PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, uuid);
try (ResultSet rs = statement.executeQuery()) {
if (rs.next()) {
lastUpdatedTime = rs.getString("LAST_UPDATED_TIME");
}
}
return lastUpdatedTime;
} catch (SQLException e) {
throw new APIMgtDAOException("Error while retrieving last access time from table : " + resourceTableName + " and entity " + uuid, e);
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.FIELD in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getPaginatedInstanceList.
/**
* Get paginated instance list
*
* @param filter Instance tFilter
* @param order The field on which to be ordered
* @param limit The maximum number of instances to be fetched
* @param page The page number
* @return Instances that are filtered through "tFilter", ordered by "order" that fits into
* 'page'th page
* @throws InstanceManagementException When an error occurs
*/
public PaginatedInstanceList getPaginatedInstanceList(String filter, final String order, final int limit, final int page) throws InstanceManagementException {
String tFilter = filter;
final PaginatedInstanceList instanceList = new PaginatedInstanceList();
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
if (tenantProcessStore.getProcessConfigMap().size() <= 0) {
instanceList.setPages(0);
return instanceList;
}
if (!tFilter.contains(" pid=")) {
tFilter = tFilter + getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet());
}
if (log.isDebugEnabled()) {
log.debug("Instance Filter:" + tFilter);
}
final InstanceFilter instanceFilter = new InstanceFilter(tFilter, order, limit);
try {
BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
bpelDb.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) throws InstanceManagementException {
Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
int pageNum = page;
if (pageNum < 0 || pageNum == Integer.MAX_VALUE) {
pageNum = 0;
}
int startIndexOfCurrentPage = pageNum * BPELConstants.ITEMS_PER_PAGE;
int endIndexOfCurrentPage = (pageNum + 1) * BPELConstants.ITEMS_PER_PAGE;
int instanceListSize = instances.size();
int pages = (int) Math.ceil((double) instanceListSize / BPELConstants.ITEMS_PER_PAGE);
instanceList.setPages(pages);
ProcessInstanceDAO[] instanceArray = instances.toArray(new ProcessInstanceDAO[instanceListSize]);
for (int i = startIndexOfCurrentPage; (i < endIndexOfCurrentPage && i < instanceListSize); i++) {
instanceList.addInstance(createLimitedInstanceInfoObject(instanceArray[i]));
}
return null;
}
});
} catch (Exception e) {
String errMsg = "Error querying instances from database. Instance Filter:" + instanceFilter.toString();
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
return instanceList;
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.FIELD in project ballerina by ballerina-lang.
the class SymbolEnter method defineStructFields.
private void defineStructFields(List<BLangStruct> structNodes, SymbolEnv pkgEnv) {
structNodes.forEach(struct -> {
// Create struct type
SymbolEnv structEnv = SymbolEnv.createPkgLevelSymbolEnv(struct, struct.symbol.scope, pkgEnv);
BStructType structType = (BStructType) struct.symbol.type;
structType.fields = struct.fields.stream().peek(field -> defineNode(field, structEnv)).map(field -> new BStructField(names.fromIdNode(field.name), field.symbol)).collect(Collectors.toList());
});
// define init function
structNodes.forEach(struct -> {
SymbolEnv structEnv = SymbolEnv.createPkgLevelSymbolEnv(struct, struct.symbol.scope, pkgEnv);
defineStructInitFunction(struct, structEnv);
});
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.FIELD in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangVariable varNode) {
// this is a field variable defined for object init function
if (varNode.isField) {
Name varName = names.fromIdNode(varNode.name);
BVarSymbol fieldVar = (BVarSymbol) symResolver.resolveObjectField(varNode.pos, env, varName, env.enclObject.symbol.type.tsymbol);
varNode.type = fieldVar.type;
varName = getFieldSymbolName(((BLangFunction) env.enclInvokable).receiver, varNode);
BVarSymbol varSymbol = defineVarSymbol(varNode.pos, varNode.flagSet, varNode.type, varName, env);
env.enclObject.initFunction.initFunctionStmts.put(fieldVar, (BLangStatement) createAssignmentStmt(varNode, varSymbol, fieldVar));
varSymbol.docTag = varNode.docTag;
varNode.symbol = varSymbol;
return;
}
// assign the type to var type node
if (varNode.type == null) {
varNode.type = symResolver.resolveTypeNode(varNode.typeNode, env);
}
Name varName = names.fromIdNode(varNode.name);
if (varName == Names.EMPTY || varName == Names.IGNORE) {
// e.g. function foo() (int);
return;
}
BVarSymbol varSymbol = defineVarSymbol(varNode.pos, varNode.flagSet, varNode.type, varName, env);
varSymbol.docTag = varNode.docTag;
varNode.symbol = varSymbol;
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.FIELD in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangObject objectNode) {
BSymbol objectSymbol = objectNode.symbol;
SymbolEnv objectEnv = SymbolEnv.createPkgLevelSymbolEnv(objectNode, objectSymbol.scope, env);
objectNode.fields.forEach(field -> analyzeNode(field, objectEnv));
analyzeNode(objectNode.initFunction, objectEnv);
objectNode.functions.forEach(f -> analyzeNode(f, objectEnv));
}
Aggregations