本文整理汇总了Java中com.avaje.ebean.RawSql类的典型用法代码示例。如果您正苦于以下问题:Java RawSql类的具体用法?Java RawSql怎么用?Java RawSql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RawSql类属于com.avaje.ebean包,在下文中一共展示了RawSql类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBudgetAsAmountByBucketAndOpex
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total budget of initiatives for a budget bucket.
*
* @param budgetBucketId
* the budget bucket id
* @param isOpex
* set to true for OPEX budget, else CAPEX
*/
public static Double getBudgetAsAmountByBucketAndOpex(Long budgetBucketId, boolean isOpex) {
String sql = "SELECT SUM(pebl.amount * pebl.currency_rate) as totalAmount FROM portfolio_entry_budget_line pebl"
+ " JOIN portfolio_entry_budget peb ON pebl.portfolio_entry_budget_id = peb.id"
+ " JOIN life_cycle_instance_planning lcip ON peb.id = lcip.portfolio_entry_budget_id"
+ " JOIN life_cycle_instance lci ON lcip.life_cycle_instance_id = lci.id" + " JOIN portfolio_entry pe ON lci.portfolio_entry_id = pe.id"
+ " WHERE pebl.deleted = 0 AND pebl.is_opex = " + isOpex + " AND pebl.budget_bucket_id = " + budgetBucketId
+ " AND peb.deleted = 0 AND pe.deleted = 0 AND lci.deleted = 0 AND lci.is_active=1 AND lcip.deleted = 0 AND lcip.is_frozen = 0";
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalAmount> query = Ebean.find(TotalAmount.class);
Double totalAmount = query.setRawSql(rawSql).findUnique().totalAmount;
if (totalAmount == null) {
return 0.0;
}
return totalAmount;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:30,代码来源:PortfolioEntryBudgetDAO.java
示例2: getTimesheetLogAsTotalHoursByPEPlanningPackage
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total timesheeted hours of a planning package.
*
* @param planningPackage
* the planning package
*/
public static BigDecimal getTimesheetLogAsTotalHoursByPEPlanningPackage(PortfolioEntryPlanningPackage planningPackage) {
String sql = "SELECT SUM(tl.hours) AS totalHours FROM timesheet_log tl " + "JOIN timesheet_entry te ON tl.timesheet_entry_id = te.id "
+ "JOIN timesheet_report tr ON te.timesheet_report_id = tr.id "
+ "WHERE tl.deleted = false AND te.deleted = false AND tr.deleted = false AND te.portfolio_entry_planning_package_id = '" + planningPackage.id
+ "'";
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalHours> query = Ebean.find(TotalHours.class);
BigDecimal totalHours = query.setRawSql(rawSql).findUnique().totalHours;
if (totalHours == null) {
return BigDecimal.ZERO;
}
return totalHours;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:26,代码来源:TimesheetDao.java
示例3: getTimesheetLogAsTotalHoursByPE
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total timesheeted hours of a portfolio entry.
*
* @param portfolioEntryId
* the portfolio entry
*/
public static BigDecimal getTimesheetLogAsTotalHoursByPE(Long portfolioEntryId) {
String sql = "SELECT SUM(tl.hours) AS totalHours FROM timesheet_log tl " + "JOIN timesheet_entry te ON tl.timesheet_entry_id = te.id "
+ "JOIN timesheet_report tr ON te.timesheet_report_id = tr.id "
+ "WHERE tl.deleted = false AND te.deleted = false AND tr.deleted = false AND te.portfolio_entry_id = '" + portfolioEntryId
+ "' AND (tr.status = '" + Status.APPROVED.name() + "' OR tr.status = '" + Status.LOCKED.name() + "' )";
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalHours> query = Ebean.find(TotalHours.class);
BigDecimal totalHours = query.setRawSql(rawSql).findUnique().totalHours;
if (totalHours == null) {
return BigDecimal.ZERO;
}
return totalHours;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:26,代码来源:TimesheetDao.java
示例4: getOrgUnitAsListByKeywordsAndFilter2
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public static List<OrgUnit> getOrgUnitAsListByKeywordsAndFilter2(String key, boolean mustBeActive, boolean mustBeSponsor, boolean mustBeDelivery) {
key = key.replace("\"", "\\\"");
String sql = "SELECT ou.id FROM `org_unit` ou LEFT OUTER JOIN `i18n_messages` im ON im.key = ou.name WHERE ou.deleted = 0";
if (mustBeActive) {
sql += " AND ou.is_active = 1";
}
if (mustBeSponsor) {
sql += " AND ou.can_sponsor = 1";
}
if (mustBeDelivery) {
sql += " AND ou.can_deliver = 1";
}
sql += " AND (im.language = '" + Http.Context.current().lang().code() + "' OR im.language IS NULL)";
sql += " AND (ou.name LIKE \"" + key + "\" OR ou.ref_id LIKE \"" + key + "\" OR im.value LIKE \"" + key + "\") ";
RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("ou.id", "id").create();
return findOrgUnit.query().setRawSql(rawSql).findList();
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:18,代码来源:OrgUnitDao.java
示例5: getPortfolioAsBudgetAmountByOpex
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total portfolio entry budget of a portfolio.
*
* @param id
* the portfolio id
* @param isOpex
* set to true for OPEX budget, else CAPEX
*/
public static Double getPortfolioAsBudgetAmountByOpex(Long id, boolean isOpex) {
String sql = "SELECT SUM(pebl.amount * pebl.currency_rate) as totalAmount FROM portfolio_entry_budget_line pebl "
+ "JOIN portfolio_entry_budget peb ON pebl.portfolio_entry_budget_id=peb.id "
+ "JOIN life_cycle_instance_planning lcip ON peb.id = lcip.portfolio_entry_budget_id "
+ "JOIN portfolio_entry pe ON lcip.life_cycle_instance_id = pe.active_life_cycle_instance_id "
+ "JOIN portfolio_has_portfolio_entry phpe ON pe.id = phpe.portfolio_entry_id " + "WHERE pebl.deleted=0 AND pebl.is_opex=" + isOpex
+ " AND peb.deleted=0 AND lcip.deleted=0 AND lcip.is_frozen=0 " + "AND pe.deleted=0 AND pe.archived=0 AND phpe.portfolio_id=" + id;
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalAmount> query = Ebean.find(TotalAmount.class);
Double totalAmount = query.setRawSql(rawSql).findUnique().totalAmount;
if (totalAmount == null) {
return 0.0;
}
return totalAmount;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:30,代码来源:PortfolioDao.java
示例6: filterByDateTime
import com.avaje.ebean.RawSql; //导入依赖的package包/类
@Override
public List<Meal> filterByDateTime(
final User user,
Integer fromDate,
Integer toDate,
Integer fromTime,
Integer toTime) {
String sql = String.format(
"SELECT id, date, description, calories FROM meal WHERE EXTRACT(HOUR_MINUTE FROM date) " +
"BETWEEN %d AND %d AND DATE(date) BETWEEN %d AND %d AND user_id=%d",
fromTime, toTime, fromDate, toDate, user.id);
RawSql rawSq = RawSqlBuilder
.parse(sql)
.create();
return find
.setRawSql(rawSq)
.orderBy("date desc")
.findList();
}
开发者ID:Coderaio,项目名称:sample-play-angular-app,代码行数:20,代码来源:MealRepositoryImpl.java
示例7: getRecipientsForCustomer
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public List<RecipientModel> getRecipientsForCustomer(Long id) {
String recipientsSql =
"select distinct r.id, r.email " +
" from pos_recipient r, pos_order o , POS_ORDER_RECIPIENTS pr, pos_customer c " +
" where r.id = pr.recipient_id" +
" and pr.order_id = o.id" +
" and o.customer_id = c.id ";
RawSql rawSql = RawSqlBuilder.parse(recipientsSql).
columnMapping("r.id", "id")
.columnMapping("r.email", "email")
.create();
Query<RecipientModel> query = Ebean.find(RecipientModel.class);
query.setRawSql(rawSql)
.where().eq("c.id", id);
List<RecipientModel> recipients = query.findList();
return recipients;
}
开发者ID:metno,项目名称:poseidon-rest,代码行数:23,代码来源:RecipientService.java
示例8: findBestSaleForAmount
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Find best sale for amount.
*
* @param shop
* the shop
* @param amount
* the amount
* @param stackSizes
* the stack sizes
* @return the auction sale
*/
public AuctionSale findBestSaleForAmount(AuctionShop shop, int amount, List<Integer> stackSizes) {
String amountCondition;
if (amount > 0) {
amountCondition = String.format("= %d", amount);
} else {
amountCondition = String.format("not in (%s)", StringUtils.join(stackSizes, ","));
}
String bestPriceReq = String
.format("select bs.amount, min(unit_price) bestPrice from well_auction_sale bs inner join well_auction_sellerData bsd on bsd.id = bs.seller_data_id where bsd.shop_id=%d and bs.amount %s",
shop.getId(), amountCondition);
String sql = "from well_auction_sale s inner join (" + bestPriceReq + ") bpr on s.amount=bpr.amount and s.unit_price = bpr.bestPrice "
+ "left outer join well_auction_sellerData sd on sd.id = s.seller_data_id ";
RawSql rawSql = AuctionSale.mapRawSql("s").mapJoin("sellerData", AuctionSellerData.mapRawSql("sd")).create(sql);
return refreshSale(db.find(AuctionSale.class).setRawSql(rawSql).where(String.format("sd.shop_id=:shop and amount %s", amountCondition))
.setParameter("shop", shop.getId()).order().asc("created").setMaxRows(1).findUnique());
}
开发者ID:ngasull,项目名称:well-auction,代码行数:33,代码来源:WellAuctionDao.java
示例9: ExistNewest
import com.avaje.ebean.RawSql; //导入依赖的package包/类
private StockRecommend ExistNewest() {
String str = String
.format("select id, create_time, "
+ " stock, open, close,"
+ " income, current, average_income, "
+ " num, total, up, down,"
+ " is_closed, account_id, app_id "
+ " from stock_recommend where (stock_recommend.open !=0 or (stock_recommend.open=0 and stock_recommend.is_closed = 1))"
+ " and stock_recommend.account_id = '%s' and stock_recommend.app_id = '%s'"
+ " order by stock_recommend.create_time desc ",
session("userId"), session("appId"));
RawSql rawSql = RawSqlBuilder.parse(str).columnMapping("id", "id")
.columnMapping("create_time", "createTime")
.columnMapping("stock", "stock.id")
.columnMapping("open", "open").columnMapping("close", "close")
.columnMapping("income", "income")
.columnMapping("current", "current")
.columnMapping("average_income", "averageIncome")
.columnMapping("num", "num").columnMapping("total", "total")
.columnMapping("up", "up").columnMapping("down", "down")
.columnMapping("is_closed", "isClosed")
.columnMapping("account_id", "accountId.id")
.columnMapping("app_id", "application.id").create();
StockRecommend theOne = Ebean.find(StockRecommend.class)
.setRawSql(rawSql).setFirstRow(0).setMaxRows(1).findUnique();
return theOne;
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:30,代码来源:StockRecommendController.java
示例10: ExistList
import com.avaje.ebean.RawSql; //导入依赖的package包/类
private List<StockRecommend> ExistList(String accountId) {
String str = String
.format("select id, create_time, "
+ " stock, open, close,"
+ " income, current, average_income, "
+ " num, total, up, down,"
+ " is_closed, account_id, app_id "
+ " from stock_recommend where (stock_recommend.open !=0 or (stock_recommend.open=0 and stock_recommend.is_closed = 1))"
+ " and stock_recommend.account_id = '%s' and stock_recommend.app_id = '%s'"
+ " order by stock_recommend.create_time desc ",
accountId, session("appId"));
RawSql rawSql = RawSqlBuilder.parse(str).columnMapping("id", "id")
.columnMapping("create_time", "createTime")
.columnMapping("stock", "stock.id")
.columnMapping("open", "open").columnMapping("close", "close")
.columnMapping("income", "income")
.columnMapping("current", "current")
.columnMapping("average_income", "averageIncome")
.columnMapping("num", "num").columnMapping("total", "total")
.columnMapping("up", "up").columnMapping("down", "down")
.columnMapping("is_closed", "isClosed")
.columnMapping("account_id", "accountId.id")
.columnMapping("app_id", "application.id").create();
List<StockRecommend> theOne = Ebean.find(StockRecommend.class)
.setRawSql(rawSql).findList();
return theOne;
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:30,代码来源:StockRecommendController.java
示例11: getManList
import com.avaje.ebean.RawSql; //导入依赖的package包/类
private List<CharmSortResult> getManList(PERIOD_TYPE periodType, int pageNumber, int sizePerPage){
Date nowDate = new Date();
Date startDate = getStartDate(nowDate, periodType);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String appId = session("appId");
String sql = String.format(
"select charm_value.receiver_id, name, head_image, search_id, sum(charm_value)sumValue, is_verified from charm_value"
+ " join app_profile on app_profile.account_id = charm_value.receiver_id"
+ " where charm_value.app_id = '%s' and app_profile.sex = 0 and charm_value.create_time >= '%s' and charm_value.create_time <= '%s'"
+ " group by charm_value.receiver_id order by if (isnull(head_image) or head_image = '', 1, 0), sumValue desc",
appId, sdf.format(startDate), sdf.format(nowDate));
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("charm_value.receiver_id", "account_id")
.columnMapping("name", "name")
.columnMapping("head_image", "head_image")
.columnMapping("search_id", "search_id")
.columnMapping("sum(charm_value)sumValue", "sum_charm")
.create();
Query<CharmSortResult> query = Ebean.find(CharmSortResult.class);
query.setRawSql(rawSql);
List<CharmSortResult> list =
query
.setFirstRow(pageNumber*sizePerPage)
.setMaxRows(sizePerPage)
.findList();
return list;
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:37,代码来源:HotPeopleListController.java
示例12: getWomanList
import com.avaje.ebean.RawSql; //导入依赖的package包/类
private List<CharmSortResult> getWomanList(PERIOD_TYPE periodType, int pageNumber, int sizePerPage){
Date nowDate = new Date();
Date startDate = getStartDate(nowDate, periodType);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String appId = session("appId");
String sql = String.format(
"select charm_value.receiver_id, name, head_image, search_id, sum(charm_value)sumValue, is_verified from charm_value"
+ " join app_profile on app_profile.account_id = charm_value.receiver_id"
+ " where charm_value.app_id = '%s' and app_profile.sex = 1 and charm_value.create_time >= '%s' and charm_value.create_time <= '%s'"
+ " group by charm_value.receiver_id order by if (isnull(head_image) or head_image = '', 1, 0), sumValue desc",
appId, sdf.format(startDate), sdf.format(nowDate));
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("charm_value.receiver_id", "account_id")
.columnMapping("name", "name")
.columnMapping("head_image", "head_image")
.columnMapping("search_id", "search_id")
.columnMapping("sum(charm_value)sumValue", "sum_charm")
.create();
Query<CharmSortResult> query = Ebean.find(CharmSortResult.class);
query.setRawSql(rawSql);
List<CharmSortResult> list =
query
.setFirstRow(pageNumber*sizePerPage)
.setMaxRows(sizePerPage)
.findList();
return list;
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:37,代码来源:HotPeopleListController.java
示例13: getRichList
import com.avaje.ebean.RawSql; //导入依赖的package包/类
private List<CharmSortResult> getRichList(PERIOD_TYPE periodType, int pageNumber, int sizePerPage){
Date nowDate = new Date();
Date startDate = getStartDate(nowDate, periodType);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String appId = session("appId");
//use flower instead of money, please replace count(money_record.account_id) back to sum(money)
String sql = String.format(
"select money_record.account_id, name, head_image, search_id, count(money_record.account_id) sumValue, is_verified from money_record"
+ " join app_profile on app_profile.account_id = money_record.account_id"
+ " where money_record.app_id = '%s' and money_record.create_time >= '%s' and money_record.create_time <= '%s'"
+ " group by money_record.account_id order by if (isnull(head_image) or head_image = '', 1, 0), sumValue desc",
appId, sdf.format(startDate), sdf.format(nowDate));
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("money_record.account_id", "account_id")
.columnMapping("name", "name")
.columnMapping("head_image", "head_image")
.columnMapping("search_id", "search_id")
.columnMapping("count(money_record.account_id)", "sum_charm")
.create();
Query<CharmSortResult> query = Ebean.find(CharmSortResult.class);
query.setRawSql(rawSql);
List<CharmSortResult> list =
query
.setFirstRow(pageNumber*sizePerPage)
.setMaxRows(sizePerPage)
.findList();
return list;
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:38,代码来源:HotPeopleListController.java
示例14: readNew
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public Result readNew(Integer pageNumber, Integer sizePerPage) {
try {
String sql = String.format(
"select t1.account_id,t1.app_id from account t0 join app_profile t1 on t0.id = t1.account_id");
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("t1.account_id", "id.accountId")
.columnMapping("t1.app_id","id.appId")
.create();
Query<AppProfile> query = Ebean.find(AppProfile.class);
query.setRawSql(rawSql)
.where().eq("is_verified",1)
.setFirstRow(pageNumber*sizePerPage)
.setMaxRows(sizePerPage)
.orderBy("create_time desc")
.findList();;
List<AppProfile> newList = query.findList();
// dao xu
return ok(Json.toJson(newList));
}
catch (Throwable e) {
return status(ErrDefinition.E_PROGRAM_CONTENT_READ_FAILED,
Messages.get("programcontent.failure"));
}
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:31,代码来源:ProgramContentController.java
示例15: read
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public Result read() {
try {
String sql = String.format(
"select id, shop_id, user_id, create_time from shake_record"
+" join shop on shop.id = shop_id"
+" where shop.app_id = %s and user_id = %s",
session("appId"), session("userId"));
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("id", "id")
.columnMapping("shop_id", "shop_id")
.columnMapping("user_id", "user_id")
.columnMapping("create_time", "create_time")
.create();
Query<ShakeRecord> query = Ebean.find(ShakeRecord.class);
query.setRawSql(rawSql);
List<ShakeRecord> shakeList = query.findList();
return ok(Json.toJson(shakeList));
}
catch (Throwable e) {
return status(ErrDefinition.E_SHAKE_RECORD_READ_ERROR,
Messages.get("shakerecord.failure"));
}
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:30,代码来源:ShakeRecordController.java
示例16: readAll
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public Result readAll() {
try {
String sql = String.format(
"select id, shop_id, user_id, create_time from shake_record"
+" join shop on shop.id = shop_id"
+" where shop.app_id = %s",
session("appId"));
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("id", "id")
.columnMapping("shop_id", "shop_id")
.columnMapping("user_id", "user_id")
.columnMapping("create_time", "create_time")
.create();
Query<ShakeRecord> query = Ebean.find(ShakeRecord.class);
query.setRawSql(rawSql);
List<ShakeRecord> shakeList = query.findList();
return ok(Json.toJson(shakeList));
}
catch (Throwable e) {
return status(ErrDefinition.E_SHAKE_RECORD_READ_ERROR,
Messages.get("shakerecord.failure"));
}
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:30,代码来源:ShakeRecordController.java
示例17: queryResult
import com.avaje.ebean.RawSql; //导入依赖的package包/类
public Result queryResult(String contentId) {
try {
String sql = String.format(
//"select t1.description description, count(*) number from activity_result t0 inner join activity_choice t1 on t0.choice_id = t1.id where t0.activity_content_id = '%s' group by t0.choice_id order by number desc;", contentId);
"select t1.description description, count(t0.choice_id) number from activity_choice t1 left join activity_result t0 on t0.choice_id = t1.id where t1.activity_content_id = '%s' group by t1.id order by number desc;", contentId);
RawSql rawSql =
RawSqlBuilder.parse(sql)
.columnMapping("t1.description", "name")
.columnMapping("count(t0.choice_id)", "number")
.create();
Query<ResultGroup> query = Ebean.find(ResultGroup.class);
query.setRawSql(rawSql);
List<ResultGroup> list = query.findList();
return ok(Json.toJson(list));
}
catch (Throwable e) {
return status(ErrDefinition.E_ACTIVITY_RESULT_READ_FAILED,
Messages.get("activityresult.failure"));
}
}
开发者ID:chengxp3,项目名称:galaxy,代码行数:29,代码来源:ActivityResultController.java
示例18: getStoryPointsByPE
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total story points of a portfolio entry for direct requirements.
*
* @param portfolioEntryId
* the portfolio entry id
* @param isClosed
* if true: get only closed requirements, if false: get only
* non-closed requirements, if null: get all requirements
*/
public static Integer getStoryPointsByPE(Long portfolioEntryId, Boolean isClosed) {
String sql = "SELECT SUM(r.story_points) AS totalStoryPoints " + "FROM requirement r "
+ "JOIN requirement_status rs ON r.requirement_status_id = rs.id AND rs.deleted = 0 " + "WHERE r.deleted = 0 AND r.portfolio_entry_id = "
+ portfolioEntryId;
if (isClosed != null) {
if (isClosed) {
sql += " AND (rs.type = '" + RequirementStatus.Type.CLOSED.name() + "' OR rs.type = '" + RequirementStatus.Type.DEPLOYED.name() + "')";
} else {
sql += " AND rs.type <> '" + RequirementStatus.Type.CLOSED.name() + "' AND rs.type <> '" + RequirementStatus.Type.DEPLOYED.name() + "'";
}
}
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalStoryPoints> query = Ebean.find(TotalStoryPoints.class);
Integer totalStoryPoints = query.setRawSql(rawSql).findUnique().totalStoryPoints;
if (totalStoryPoints == null) {
return 0;
}
return totalStoryPoints;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:36,代码来源:RequirementDAO.java
示例19: getRequirementAsCountByPE
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total number of direct requirement of a portfolio entry.
*
* @param portfolioEntryId
* the portfolio entry id
* @param isClosed
* if true: get only closed requirements, if false: get only
* non-closed requirements, if null: get all requirements
*/
public static Integer getRequirementAsCountByPE(Long portfolioEntryId, Boolean isClosed) {
String sql = "SELECT COUNT(r.id) AS totalRequirement " + "FROM requirement r "
+ "JOIN requirement_status rs ON r.requirement_status_id = rs.id AND rs.deleted = 0 " + "WHERE r.deleted = 0 AND r.portfolio_entry_id = "
+ portfolioEntryId;
if (isClosed != null) {
if (isClosed) {
sql += " AND (rs.type = '" + RequirementStatus.Type.CLOSED.name() + "' OR rs.type = '" + RequirementStatus.Type.DEPLOYED.name() + "')";
} else {
sql += " AND rs.type <> '" + RequirementStatus.Type.CLOSED.name() + "' AND rs.type <> '" + RequirementStatus.Type.DEPLOYED.name() + "'";
}
}
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalRequirement> query = Ebean.find(TotalRequirement.class);
Integer totalRequirement = query.setRawSql(rawSql).findUnique().totalRequirement;
if (totalRequirement == null) {
return 0;
}
return totalRequirement;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:36,代码来源:RequirementDAO.java
示例20: getPEPlanAllocatedActorAsDaysByPEAndConfirmed
import com.avaje.ebean.RawSql; //导入依赖的package包/类
/**
* Get the total allocated actors days (for the current resource plan) of a
* portfolio entry.
*
* @param portfolioEntry
* the portfolio entry
* @param isConfirmed
* set to true for confirmed resource; to false for non-confirmed
* resource; to null for all
*/
public static BigDecimal getPEPlanAllocatedActorAsDaysByPEAndConfirmed(PortfolioEntry portfolioEntry, Boolean isConfirmed) {
// get the current life cycle planning
LifeCycleInstancePlanning planning = portfolioEntry.activeLifeCycleInstance.getCurrentLifeCycleInstancePlanning();
// get the resource plan
PortfolioEntryResourcePlan resourcePlan = planning.portfolioEntryResourcePlan;
String sql = "SELECT SUM(perpaa.days) as totalDays FROM portfolio_entry_resource_plan_allocated_actor perpaa WHERE perpaa.deleted = 0 "
+ "AND perpaa.portfolio_entry_resource_plan_id = '" + resourcePlan.id + "'";
if (isConfirmed != null) {
if (isConfirmed) {
sql += " AND perpaa.portfolio_entry_resource_plan_allocation_status_type_id = (SELECT id FROM portfolio_entry_resource_plan_allocation_status_type WHERE status = 'CONFIRMED')";
} else {
sql += " AND perpaa.portfolio_entry_resource_plan_allocation_status_type_id in (SELECT id FROM portfolio_entry_resource_plan_allocation_status_type WHERE status != 'CONFIRMED')";
}
}
RawSql rawSql = RawSqlBuilder.parse(sql).create();
Query<TotalDays> query = Ebean.find(TotalDays.class);
BigDecimal totalDays = query.setRawSql(rawSql).findUnique().totalDays;
if (totalDays == null) {
return BigDecimal.ZERO;
}
return totalDays;
}
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:42,代码来源:PortfolioEntryResourcePlanDAO.java
注:本文中的com.avaje.ebean.RawSql类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论