Java 类play.mvc.With 实例源码

项目:exam    文件:ExamController.java   
@With(ExamUpdateSanitizer.class)
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result updateExam(Long id) {
    Exam exam = prototypeQuery().where().idEq(id).findUnique();
    if (exam == null) {
        return notFound();
    }
    User user = getLoggedUser();
    if (exam.isOwnedOrCreatedBy(user) || getLoggedUser().hasRole("ADMIN", getSession())) {
        return updateTemporalFieldsAndValidate(exam, user)
                .orElseGet(() -> updateStateAndValidate(exam)
                        .orElseGet(() -> handleExamUpdate(exam)));
    } else {
        return forbidden("sitnet_error_access_forbidden");
    }
}
项目:exam    文件:EnrolmentController.java   
@JsonValidator(schema = "enrolmentInfo")
@With(EnrolmentInformationSanitizer.class)
@Restrict({@Group("STUDENT")})
public Result updateEnrolment(Long id) {
    String info = request().attrs().getOptional(Attrs.ENROLMENT_INFORMATION).orElse(null);
    ExamEnrolment enrolment = Ebean.find(ExamEnrolment.class).where()
            .idEq(id)
            .eq("user", getLoggedUser())
            .findUnique();
    if (enrolment == null) {
        return notFound("enrolment not found");
    }
    enrolment.setInformation(info);
    enrolment.update();
    return ok();
}
项目:maf-desktop-app    文件:PortfolioEntryDataSyndicationController.java   
/**
 * Display the details of an agreement link with management capabilities.
 * 
 * @param id
 *            the portfolio entry id
 * @param agreementLinkId
 *            the agreement link id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result viewAgreementLink(Long id, Long agreementLinkId) {

    // get the portfolio entry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the agreement link
    DataSyndicationAgreementLink agreementLink = null;
    try {
        agreementLink = dataSyndicationService.getAgreementLink(agreementLinkId);
        if (agreementLink == null) {
            return notFound(views.html.error.not_found.render(""));
        }
    } catch (Exception e) {
        Logger.error("DataSyndication viewAgreementLink unexpected error", e);
        return ok(views.html.core.portfolioentrydatasyndication.communication_error.render(portfolioEntry));
    }

    // define if the instance is the master or slave of the agreement link
    Boolean isMasterAgreementLink = agreementLink.agreement.masterPartner.domain.equals(dataSyndicationService.getCurrentDomain());

    return ok(views.html.core.portfolioentrydatasyndication.agreement_link_view.render(portfolioEntry, isMasterAgreementLink, agreementLink));

}
项目:maf-desktop-app    文件:PortfolioEntryStakeholderController.java   
/**
 * Form to create/edit a direct stakeholder of a portfolio entry.
 * 
 * @param id
 *            the portfolio entry id
 * @param stakeholderId
 *            the stakeholder id (set to 0 for create case)
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result manage(Long id, Long stakeholderId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // initiate the form with the template
    Form<StakeholderFormData> stakeholderForm = formTemplate;

    // edit case: inject values
    if (!stakeholderId.equals(Long.valueOf(0))) {
        Stakeholder stakeholder = StakeholderDao.getStakeholderById(stakeholderId);

        // security: the portfolioEntry must be related to the object
        if (!stakeholder.portfolioEntry.id.equals(id)) {
            return forbidden(views.html.error.access_forbidden.render(""));
        }

        stakeholderForm = formTemplate.fill(new StakeholderFormData(stakeholder));
    }

    return ok(views.html.core.portfolioentrystakeholder.stakeholder_manage.render(portfolioEntry, stakeholderForm));
}
项目:maf-desktop-app    文件:PortfolioEntryStakeholderController.java   
/**
 * Delete a direct stakeholder of a portfolio entry.
 * 
 * @param id
 *            the portfolio entry id
 * @param stakeholderId
 *            the stakeholder id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result delete(Long id, Long stakeholderId) {

    // get the stakeholder
    Stakeholder stakeholder = StakeholderDao.getStakeholderById(stakeholderId);

    // security: the portfolioEntry must be related to the object
    if (!stakeholder.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    // set the delete flag to true
    stakeholder.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.portfolio_entry_stakeholder.delete"));

    return redirect(controllers.core.routes.PortfolioEntryStakeholderController.index(id));
}
项目:maf-desktop-app    文件:BudgetBucketController.java   
/**
 * Form to edit a budget bucket.
 * 
 * @param id
 *            the budget bucket id
 */
@With(CheckBudgetBucketExists.class)
@Dynamic(IMafConstants.BUDGET_BUCKET_EDIT_DYNAMIC_PERMISSION)
public Result edit(Long id) {

    // get the budget bucket
    BudgetBucket budgetBucket = BudgetBucketDAO.getBudgetBucketById(id);

    // load the form
    Form<BudgetBucketFormData> form = formTemplate.fill(new BudgetBucketFormData(budgetBucket));

    // add the custom attributes values
    this.getCustomAttributeManagerService().fillWithValues(form, BudgetBucket.class, id);

    return ok(views.html.core.budgetbucket.budget_bucket_edit.render(budgetBucket, form));
}
项目:maf-desktop-app    文件:PortfolioEntryPlanningController.java   
/**
 * Display the form to reallocate an org unit to an actor.
 * 
 * @param id
 *            the portfolio entry id
 * @param allocatedOrgUnitId
 *            the allocated org unit
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result reallocateOrgUnit(Long id, Long allocatedOrgUnitId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the allocated org unit
    PortfolioEntryResourcePlanAllocatedOrgUnit allocatedOrgUnit = PortfolioEntryResourcePlanDAO.getPEResourcePlanAllocatedOrgUnitById(allocatedOrgUnitId);

    // get the org unit
    OrgUnit orgUnit = allocatedOrgUnit.orgUnit;

    // security: the portfolioEntry must be related to the object
    if (!allocatedOrgUnit.portfolioEntryResourcePlan.lifeCycleInstancePlannings.get(0).lifeCycleInstance.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    Form<PortfolioEntryResourcePlanAllocatedActorFormData> allocatedActorForm = reallocateOrgUnitFormTemplate
            .fill(new PortfolioEntryResourcePlanAllocatedActorFormData(allocatedOrgUnit));

    return ok(views.html.core.portfolioentryplanning.allocated_org_unit_reallocate.render(portfolioEntry, orgUnit, allocatedActorForm));

}
项目:maf-desktop-app    文件:BudgetBucketController.java   
/**
 * Create or edit a budget bucket line.
 * 
 * @param id
 *            the budget bucket id
 * @param lineId
 *            the budget bucket line id, set to 0 for create case
 */
@With(CheckBudgetBucketExists.class)
@Dynamic(IMafConstants.BUDGET_BUCKET_EDIT_DYNAMIC_PERMISSION)
public Result manageLine(Long id, Long lineId) {

    // get the budget bucket
    BudgetBucket budgetBucket = BudgetBucketDAO.getBudgetBucketById(id);

    // initiate the form with the template
    Form<BudgetBucketLineFormData> lineForm = lineFormTemplate;

    // edit case: inject values
    if (!lineId.equals(Long.valueOf(0))) {

        BudgetBucketLine budgetBucketLine = BudgetBucketDAO.getBudgetBucketLineById(lineId);

        // security: the budget bucket must be related to the object
        if (!budgetBucketLine.budgetBucket.id.equals(id)) {
            return forbidden(views.html.error.access_forbidden.render(""));
        }

        lineForm = lineFormTemplate.fill(new BudgetBucketLineFormData(budgetBucketLine));
    }

    return ok(views.html.core.budgetbucket.budget_bucket_line_manage.render(budgetBucket, lineForm));
}
项目:maf-desktop-app    文件:BudgetBucketController.java   
/**
 * Delete a budget bucket line.
 * 
 * @param id
 *            the budget bucket id
 * @param lineId
 *            the budget bucket line id
 */
@With(CheckBudgetBucketExists.class)
@Dynamic(IMafConstants.BUDGET_BUCKET_EDIT_DYNAMIC_PERMISSION)
public Result deleteLine(Long id, Long lineId) {

    // get the budget bucket line
    BudgetBucketLine line = BudgetBucketDAO.getBudgetBucketLineById(lineId);

    // security: the budget bucket must be related to the object
    if (!line.budgetBucket.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    // set the delete flag to true
    line.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.budget_bucket.line.delete.successful"));

    return redirect(controllers.core.routes.BudgetBucketController.view(id, 0, 0));
}
项目:maf-desktop-app    文件:PortfolioEntryFinancialController.java   
/**
 * Display the details of a budget line.
 * 
 * @param id
 *            the portfolio entry id
 * @param budgetLineId
 *            the budget line id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_FINANCIAL_VIEW_DYNAMIC_PERMISSION)
public Result viewBudgetLine(Long id, Long budgetLineId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the budget line
    PortfolioEntryBudgetLine budgetLine = PortfolioEntryBudgetDAO.getPEBudgetLineById(budgetLineId);

    // construct the corresponding form data (for the custom attributes)
    PortfolioEntryBudgetLineFormData portfolioEntryBudgetLineFormData = new PortfolioEntryBudgetLineFormData(budgetLine);

    return ok(
            views.html.core.portfolioentryfinancial.portfolio_entry_budget_line_view.render(portfolioEntry, budgetLine, portfolioEntryBudgetLineFormData));
}
项目:maf-desktop-app    文件:PortfolioEntryFinancialController.java   
/**
 * Display the details of a work order.
 * 
 * @param id
 *            the portfolio entry id
 * @param workOrderId
 *            the work order id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_FINANCIAL_VIEW_DYNAMIC_PERMISSION)
public Result viewWorkOrder(Long id, Long workOrderId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the work order
    WorkOrder workOrder = WorkOrderDAO.getWorkOrderById(workOrderId);

    // construct the corresponding form data (for the custom attributes)
    WorkOrderFormData workOrderFormData = new WorkOrderFormData(workOrder);

    return ok(views.html.core.portfolioentryfinancial.portfolio_entry_work_order_view.render(portfolioEntry, workOrder, workOrderFormData));
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Display the list of events.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result events(Long id) {

    // get the portfolio entry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    try {

        // get the filter config
        String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
        FilterConfig<PortfolioEntryEventListView> filterConfig = this.getTableProvider().get().portfolioEntryEvent.filterConfig.getCurrent(uid,
                request());

        // get the table
        Pair<Table<PortfolioEntryEventListView>, Pagination<PortfolioEntryEvent>> t = getEventsTable(id, filterConfig);

        return ok(views.html.core.portfolioentrystatusreporting.events.render(portfolioEntry, t.getLeft(), t.getRight(), filterConfig));

    } catch (Exception e) {

        return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin());

    }
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Delete a risk.
 * 
 * @param id
 *            the portfolio entry id
 * @param reportId
 *            the report id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result deleteRisk(Long id, Long riskId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the portfolioEntry risk
    PortfolioEntryRisk portfolioEntryRisk = PortfolioEntryRiskDao.getPERiskById(riskId);

    // security: the portfolioEntry must be related to the object
    if (!portfolioEntryRisk.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    portfolioEntryRisk.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.portfolio_entry_status_reporting.event.delete.successful"));
    return redirect(controllers.core.routes.PortfolioEntryStatusReportingController.registers(id, 0, 0, 0, false, false));
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Form to add an attachment to a report.
 * 
 * @param id
 *            the portfolio entry id
 * @param reportId
 *            the report id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result createReportAttachment(Long id, Long reportId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the report
    PortfolioEntryReport report = PortfolioEntryReportDao.getPEReportById(reportId);

    // construct the form
    Form<AttachmentFormData> attachmentForm = attachmentFormTemplate.fill(new AttachmentFormData());

    return ok(views.html.core.portfolioentrystatusreporting.report_attachment_create.render(portfolioEntry, report, attachmentForm));

}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Display the details of a portfolio entry risk/issue.
 * 
 * @param id
 *            the portfolio entry id
 * @param riskId
 *            the risk/issue id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result viewRisk(Long id, Long riskId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the portfolioEntry risk
    PortfolioEntryRisk portfolioEntryRisk = PortfolioEntryRiskDao.getPERiskById(riskId);

    // construct the corresponding form data (for the custom attributes)
    PortfolioEntryRiskFormData portfolioEntryRiskFormData = new PortfolioEntryRiskFormData(portfolioEntryRisk);

    // security: the portfolioEntry must be related to the object
    if (!portfolioEntryRisk.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    return ok(views.html.core.portfolioentrystatusreporting.risk_view.render(portfolioEntry, portfolioEntryRisk, portfolioEntryRiskFormData));
}
项目:maf-desktop-app    文件:PortfolioEntryPlanningController.java   
/**
 * Delete an allocated actor.
 * 
 * @param id
 *            the portfolio entry id
 * @param allocatedActorId
 *            the allocated actor id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result deleteAllocatedActor(Long id, Long allocatedActorId) {

    // get the allocated actor
    PortfolioEntryResourcePlanAllocatedActor allocatedActor = PortfolioEntryResourcePlanDAO.getPEPlanAllocatedActorById(allocatedActorId);

    // security: the portfolioEntry must be related to the object
    if (!allocatedActor.portfolioEntryResourcePlan.lifeCycleInstancePlannings.get(0).lifeCycleInstance.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    // set the delete flag to true
    allocatedActor.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.portfolio_entry_planning.allocated_actor.delete.successful"));

    return redirect(controllers.core.routes.PortfolioEntryPlanningController.resources(id));
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Filter the attachments files.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result docsFilter(Long id) {

    try {

        // get the filter config
        String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
        FilterConfig<PortfolioEntryAttachmentListView> filterConfig = this.getTableProvider().get().docsTableDefinition.filterConfig.persistCurrentInDefault(uid, request());

        if (filterConfig == null) {
            return ok(views.html.framework_views.parts.table.dynamic_tableview_no_more_compatible.render());
        } else {

            // get the table
            Pair<Table<PortfolioEntryAttachmentListView>, Pagination<Attachment>> t = getDocsTable(id, filterConfig);

            return ok(views.html.framework_views.parts.table.dynamic_tableview.render(t.getLeft(), t.getRight()));

        }

    } catch (Exception e) {
        return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin());
    }
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Display the list of attachments.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result docs(Long id) {

    try {

        // get the filter config
        String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
        FilterConfig<PortfolioEntryAttachmentListView> filterConfig = this.getTableProvider().get().docsTableDefinition.filterConfig.getCurrent(uid, request());

        // get the table
        Pair<Table<PortfolioEntryAttachmentListView>, Pagination<Attachment>> t = getDocsTable(id,filterConfig);

        //
        return ok(views.html.core.portfolioentrystatusreporting.docs.render(PortfolioEntryDao.getPEById(id), t.getLeft(), t.getRight(), filterConfig));

    } catch (Exception e) {

        return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin());

    }
}
项目:maf-desktop-app    文件:PortfolioEntryStatusReportingController.java   
/**
 * Filter the timesheet logs.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result timesheetsFilter(Long id) {

    try {

        // get the filter config
        String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
        FilterConfig<TimesheetLogListView> filterConfig = this.getTableProvider().get().timesheetLog.filterConfig.persistCurrentInDefault(uid, request());

        if (filterConfig == null) {
            return ok(views.html.framework_views.parts.table.dynamic_tableview_no_more_compatible.render());
        } else {

            // get the table
            Pair<Table<TimesheetLogListView>, Pagination<TimesheetLog>> t = getTimesheetsTable(id, filterConfig);

            return ok(views.html.framework_views.parts.table.dynamic_tableview.render(t.getLeft(), t.getRight()));

        }

    } catch (Exception e) {
        return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin());
    }
}
项目:maf-desktop-app    文件:PortfolioEntryController.java   
/**
 * Form to edit the standard attributes of portfolio entry.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result edit(Long id) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // construct the form
    Form<PortfolioEntryEditFormData> portfolioEntryForm = portfolioEntryEditFormData.fill(new PortfolioEntryEditFormData(portfolioEntry));

    // add the custom attributes
    this.getCustomAttributeManagerService().fillWithValues(portfolioEntryForm, PortfolioEntry.class, id);

    return ok(views.html.core.portfolioentry.portfolio_entry_edit.render(portfolioEntry, portfolioEntryForm,
            PortfolioEntryDao.getPETypeActiveAsVH(portfolioEntry.portfolioEntryType.isRelease),
            getPreferenceManagerPlugin().getPreferenceValueAsBoolean(IMafConstants.READONLY_GOVERNANCE_ID_PREFERENCE)));
}
项目:maf-desktop-app    文件:PortfolioEntryPlanningController.java   
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result resourcesAllocatedActorFilter(Long id) throws AccountManagementException {

    String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
    FilterConfig<PortfolioEntryResourcePlanAllocatedActorListView> filterConfig = this.getTableProvider().get().portfolioEntryResourcePlanAllocatedActor.filterConfig.persistCurrentInDefault(uid, request());

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // Get resource plan
    PortfolioEntryResourcePlan resourcePlan = getResourcePlan(portfolioEntry);

    if (filterConfig == null) {
        return ok(views.html.framework_views.parts.table.dynamic_tableview_no_more_compatible.render());
    } else {
        Pair<Table<PortfolioEntryResourcePlanAllocatedActorListView>, Pagination<PortfolioEntryResourcePlanAllocatedActor>> t = getAllocatedActorTable(resourcePlan, filterConfig);
        return ok(views.html.framework_views.parts.table.dynamic_tableview.render(t.getLeft(), t.getRight()));
    }
}
项目:maf-desktop-app    文件:PortfolioEntryController.java   
/**
 * Delete a portfolio entry.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DELETE_DYNAMIC_PERMISSION)
public Result delete(Long id) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // set the delete flag to true
    portfolioEntry.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.portfolio_entry.delete.successful", portfolioEntry.portfolioEntryType.getName().toLowerCase()));

    // update the licenses number
    getLicensesManagementService().updateConsumedPortfolioEntries();

    return redirect(controllers.core.routes.RoadmapController.index());
}
项目:maf-desktop-app    文件:OrgUnitController.java   
/**
 * Display the active portfolio entries of the org unit. direct stakeholder.
 * 
 * @param id
 *            the org unit id
 * @param page
 *            the current page
 */
@With(CheckOrgUnitExists.class)
@Dynamic(IMafConstants.ORG_UNIT_VIEW_DYNAMIC_PERMISSION)
public Result listPortfolioEntries(Long id, Integer page) {

    // get the org unit
    OrgUnit orgUnit = OrgUnitDao.getOrgUnitById(id);

    // get the portfolio entries
    Pagination<PortfolioEntry> pagination = PortfolioEntryDao.getPEActiveAsPaginationByOrgUnit(this.getPreferenceManagerPlugin(), id);
    pagination.setCurrentPage(page);

    List<PortfolioEntryListView> portfolioEntriesView = new ArrayList<PortfolioEntryListView>();
    for (PortfolioEntry portfolioEntry : pagination.getListOfObjects()) {
        portfolioEntriesView.add(new PortfolioEntryListView(portfolioEntry));
    }

    Table<PortfolioEntryListView> filledTable = this.getTableProvider().get().portfolioEntry.templateTable.fill(portfolioEntriesView,
            PortfolioEntryListView.getHideNonDefaultColumns(true, true));

    return ok(views.html.core.orgunit.org_unit_portfolio_entry_list.render(orgUnit, filledTable, pagination));
}
项目:maf-desktop-app    文件:PortfolioEntryPlanningController.java   
/**
 * Delete an allocated competency.
 * 
 * @param id
 *            the portfolio entry id
 * @param allocatedCompetencyId
 *            the allocated competency id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result deleteAllocatedCompetency(Long id, Long allocatedCompetencyId) {

    // get the allocated competency
    PortfolioEntryResourcePlanAllocatedCompetency allocatedCompetency = PortfolioEntryResourcePlanDAO
            .getPEResourcePlanAllocatedCompetencyById(allocatedCompetencyId);

    // security: the portfolioEntry must be related to the object
    if (!allocatedCompetency.portfolioEntryResourcePlan.lifeCycleInstancePlannings.get(0).lifeCycleInstance.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    // set the delete flag to true
    allocatedCompetency.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.portfolio_entry_planning.allocated_competency.delete.successful"));

    return redirect(controllers.core.routes.PortfolioEntryPlanningController.resources(id));

}
项目:maf-desktop-app    文件:ReportingController.java   
/**
 * Configure the parameters of a report in order to generate it.
 * 
 * @param id
 *            the report id
 */
@With(CheckReportingExists.class)
@Dynamic(IMafConstants.REPORTING_VIEW_DYNAMIC_PERMISSION)
public Result parametrize(Long id) {

    // get the report
    Reporting report = ReportingDao.getReportingById(id);

    if (report.isActive) {

        // load the form
        Form<ReportingParamsFormData> form = formTemplate.fill(new ReportingParamsFormData(report, getI18nMessagesPlugin().getCurrentLanguage().getCode()));

        return ok(views.html.core.reporting.parametrize.render(report, form));

    } else {
        return ok(views.html.error.access_forbidden.render(""));
    }
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Form to edit an actor (available from the details of an actor).
 * 
 * @param id
 *            the actor id
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_EDIT_DYNAMIC_PERMISSION)
public Result edit(Long id) {

    // get the actor
    Actor actor = ActorDao.getActorById(id);

    // construct the form
    Form<ActorFormData> actorForm = formTemplate.fill(new ActorFormData(actor));

    // add the custom attributes values
    this.getCustomAttributeManagerService().fillWithValues(actorForm, Actor.class, id);

    return ok(views.html.core.actor.actor_edit.render(actor, actorForm, ActorDao.getActorTypeActiveAsVH()));
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Delete an actor.
 * 
 * @param id
 *            the actor id
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_DELETE_DYNAMIC_PERMISSION)
public Result delete(Long id) {

    // get the actor
    Actor actor = ActorDao.getActorById(id);

    // delete the actor
    actor.doDelete();

    // success message
    Utilities.sendSuccessFlashMessage(Msg.get("core.actor.delete.successful"));

    return redirect(controllers.core.routes.SearchController.index());
}
项目:maf-desktop-app    文件:PortfolioEntryGovernanceController.java   
/**
 * Manage an additional milestone in the portfolio entry governance process
 * @param id the portfolio entry id
 * @param milestoneId the milestone id (set 0 for creation)
 * @param previousMilestoneId the previous milestone id in the list (0 for first place)
 *
 * @return the additional milestone form
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result manageAdditionalMilestone(Long id, Long milestoneId, Long previousMilestoneId) {

    Form<PortfolioEntryAdditionalMilestoneFormData> portfolioEntryAdditionalMilestoneForm = portfolioEntryAdditionalMilestoneFormTemplate;

    // edit case
    if (!milestoneId.equals(0L)) {
        LifeCycleMilestone milestone = LifeCycleMilestoneDao.getLCMilestoneById(milestoneId);
        portfolioEntryAdditionalMilestoneForm = portfolioEntryAdditionalMilestoneFormTemplate.fill(new PortfolioEntryAdditionalMilestoneFormData(milestone, previousMilestoneId, getI18nMessagesPlugin()));
    }

    return ok(views.html.core.portfolioentrygovernance.planning_edit_additional_milestone_manage.render(
            PortfolioEntryDao.getPEAllById(id),
            portfolioEntryAdditionalMilestoneForm,
            LifeCycleMilestoneDao.getLCMilestoneInstanceStatusTypeActiveAsVH(),
            getMilestonesAsVH(LifeCycleMilestoneDao.getLCMilestoneAsListByPe(id))
    ));
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Display the active portfolio entries for which the actor is manager or
 * direct stakeholder.
 * 
 * @param id
 *            the actor id
 * @param page
 *            the current page
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_VIEW_DYNAMIC_PERMISSION)
public Result listPortfolioEntries(Long id, Integer page) {

    // get the actor
    Actor actor = ActorDao.getActorById(id);

    Pagination<PortfolioEntry> pagination = PortfolioEntryDao.getPEActiveAsPaginationByManagerOrDirectStakeholder(this.getPreferenceManagerPlugin(), id);
    pagination.setCurrentPage(page);

    List<PortfolioEntryListView> portfolioEntriesView = new ArrayList<PortfolioEntryListView>();
    for (PortfolioEntry portfolioEntry : pagination.getListOfObjects()) {
        portfolioEntriesView.add(new PortfolioEntryListView(portfolioEntry, StakeholderDao.getStakeholderAsListByActorAndPE(id, portfolioEntry.id)));
    }

    Table<PortfolioEntryListView> filledTable = this.getTableProvider().get().portfolioEntry.templateTable.fill(portfolioEntriesView,
            PortfolioEntryListView.getHideNonDefaultColumns(false, false));

    return ok(views.html.core.actor.actor_portfolio_entry_list.render(actor, filledTable, pagination));
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Display the active portfolios for which the actor is manager or
 * stakeholder.
 * 
 * @param id
 *            the actor id
 * @param page
 *            the current page
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_VIEW_DYNAMIC_PERMISSION)
public Result listPortfolios(Long id, Integer page) {

    // get the actor
    Actor actor = ActorDao.getActorById(id);

    Pagination<Portfolio> pagination = PortfolioDao.getPortfolioActiveAsPaginationByStakeholderOrManager(this.getPreferenceManagerPlugin(), id);
    pagination.setCurrentPage(page);

    List<PortfolioListView> portfoliosView = new ArrayList<PortfolioListView>();
    for (Portfolio portfolio : pagination.getListOfObjects()) {
        portfoliosView.add(new PortfolioListView(portfolio, StakeholderDao.getStakeholderAsListByActorAndPortfolio(id, portfolio.id)));
    }

    Table<PortfolioListView> filledTable = this.getTableProvider().get().portfolio.templateTable.fill(portfoliosView);

    return ok(views.html.core.actor.actor_portfolio_list.render(actor, filledTable, pagination));
}
项目:maf-desktop-app    文件:OrgUnitController.java   
@With(CheckOrgUnitExists.class)
@Restrict({ @Group(IMafConstants.ORG_UNIT_EDIT_ALL_PERMISSION) })
public Result delete(Long id) {

    // get the org unit
    OrgUnit orgUnit = OrgUnitDao.getOrgUnitById(id);

    // delete the org unit
    orgUnit.doDelete();

    // success message
    Utilities.sendSuccessFlashMessage(Msg.get("core.org_unit.delete.successful"));

    this.getTableProvider().flushFilterConfig();

    return redirect(controllers.core.routes.SearchController.index());
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Delete an allocated activity.
 * 
 * @param id
 *            the actor id
 * @param allocatedActivityId
 *            the allocated activity id
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_EDIT_DYNAMIC_PERMISSION)
public Result deleteAllocatedActivity(Long id, Long allocatedActivityId) {

    // get the allocated activity
    TimesheetActivityAllocatedActor allocatedActivity = TimesheetDao.getTimesheetActivityAllocatedActorById(allocatedActivityId);

    // security: the actor must be related to the object
    if (!allocatedActivity.actor.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    // set the delete flag to true
    allocatedActivity.doDelete();

    Utilities.sendSuccessFlashMessage(Msg.get("core.actor.allocated_activity.delete.successful"));

    return redirect(controllers.core.routes.ActorController.allocationDetails(id, 0, 0, false));
}
项目:maf-desktop-app    文件:ActorController.java   
/**
 * Display the capacity of the actor with management capability if enough
 * perm.
 * 
 * @param id
 *            the actor id
 * @param year
 *            the year (0 for the current)
 * 
 */
@With(CheckActorExists.class)
@Dynamic(IMafConstants.ACTOR_VIEW_DYNAMIC_PERMISSION)
public Result capacity(Long id, Integer year) {

    if (year.equals(0)) {
        year = Calendar.getInstance().get(Calendar.YEAR);
    }

    // get the actor
    Actor actor = ActorDao.getActorById(id);

    Form<ActorCapacityFormData> capacityForm = capacityFormTemplate.fill(new ActorCapacityFormData(actor, year));

    // can edit
    boolean canEdit = getSecurityService().dynamic(IMafConstants.ACTOR_EDIT_DYNAMIC_PERMISSION, "");

    return ok(views.html.core.actor.actor_capacity.render(actor, year, capacityForm, canEdit));
}
项目:maf-desktop-app    文件:PortfolioEntryGovernanceController.java   
/**
 * Form to edit the current planning of a portfolio entry.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result editPlanning(Long id) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the last planning
    LifeCycleInstancePlanning lastPlanning = LifeCyclePlanningDao.getLCInstancePlanningAsLastByPE(id);

    // get the last planned dates
    List<PlannedLifeCycleMilestoneInstance> plannedLifeCycleMilestoneInstances = LifeCyclePlanningDao.getPlannedLCMilestoneInstanceLastAsListByPE(id);

    // construct the form
    Form<PlannedDatesFormData> plannedDatesForm = plannedDatesFormTemplate.fill(new PlannedDatesFormData(plannedLifeCycleMilestoneInstances, id));

    return ok(views.html.core.portfolioentrygovernance.planning_edit.render(portfolioEntry, lastPlanning,
            governanceListViewsAsMap(plannedLifeCycleMilestoneInstances), plannedDatesForm));
}
项目:maf-desktop-app    文件:PortfolioEntryDeliveryController.java   
/**
 * Filter the deliverables.
 * 
 * @param id
 *            the portfolio entry id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result deliverablesFilter(Long id) {

    try {

        // get the filter config
        String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
        FilterConfig<DeliverableListView> filterConfig = this.getTableProvider().get().deliverable.filterConfig.persistCurrentInDefault(uid, request());

        if (filterConfig == null) {
            return ok(views.html.framework_views.parts.table.dynamic_tableview_no_more_compatible.render());
        } else {

            // get the table
            Pair<Table<DeliverableListView>, Pagination<Deliverable>> t = getDeliverablesTable(id, filterConfig);

            return ok(views.html.framework_views.parts.table.dynamic_tableview.render(t.getLeft(), t.getRight()));

        }

    } catch (Exception e) {
        return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin());
    }
}
项目:maf-desktop-app    文件:PortfolioEntryDeliveryController.java   
/**
 * Form to edit the requirements assignments of the deliverable.
 * 
 * @param id
 *            the portfolio entry id
 * @param deliverableId
 *            the deliverable id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result editDeliverableRequirements(Long id, Long deliverableId) {

    PortfolioEntryDeliverable portfolioEntryDeliverable = DeliverableDAO.getPortfolioEntryDeliverableById(id, deliverableId);

    if (!portfolioEntryDeliverable.type.equals(PortfolioEntryDeliverable.Type.OWNER)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    PortfolioEntry portfolioEntry = portfolioEntryDeliverable.getPortfolioEntry();
    Deliverable deliverable = portfolioEntryDeliverable.getDeliverable();

    // construct the form
    Form<DeliverableRequirementsFormData> deliverableRequirementsForm = deliverableRequirementsFormTemplate
            .fill(new DeliverableRequirementsFormData(portfolioEntryDeliverable));

    return ok(views.html.core.portfolioentrydelivery.deliverable_requirements_edit.render(portfolioEntry, deliverable, deliverableRequirementsForm));
}
项目:maf-desktop-app    文件:PortfolioEntryDeliveryController.java   
/**
 * View all details of a requirement.
 * 
 * @param id
 *            the portfolio entry id
 * @param requirementId
 *            the requirement id
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_DETAILS_DYNAMIC_PERMISSION)
public Result viewRequirement(Long id, Long requirementId) {

    // get the portfolio entry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // get the requirement
    Requirement requirement = RequirementDAO.getRequirementById(requirementId);

    // construct the corresponding form data (for the custom attributes)
    RequirementFormData requirementFormData = new RequirementFormData(requirement);

    // security: the portfolioEntry must be related to the object
    if (!requirement.portfolioEntry.id.equals(id)) {
        return forbidden(views.html.error.access_forbidden.render(""));
    }

    return ok(views.html.core.portfolioentrydelivery.requirement_view.render(portfolioEntry, requirement, requirementFormData));
}
项目:maf-desktop-app    文件:PortfolioController.java   
/**
 * Form to edit a portfolio (available from the details of a portfolio).
 * 
 * @param id
 *            the portfolio id
 */
@With(CheckPortfolioExists.class)
@Dynamic(IMafConstants.PORTFOLIO_EDIT_DYNAMIC_PERMISSION)
public Result edit(Long id) {

    // get the portfolio
    Portfolio portfolio = PortfolioDao.getPortfolioById(id);

    // construct the form
    Form<PortfolioFormData> portfolioForm = formTemplate.fill(new PortfolioFormData(portfolio));

    // add the custom attributes values
    this.getCustomAttributeManagerService().fillWithValues(portfolioForm, Portfolio.class, id);

    return ok(views.html.core.portfolio.portfolio_edit.render(portfolio, portfolioForm, PortfolioDao.getPortfolioTypeActiveAsVH()));
}
项目:exam    文件:UserController.java   
@JsonValidator(schema = "userLang")
@With(UserLanguageSanitizer.class)
@Restrict({@Group("ADMIN"), @Group("TEACHER"), @Group("STUDENT")})
public Result updateLanguage() {
    User user = getLoggedUser();
    String lang = request().attrs().get(Attrs.LANG);
    Language language = Ebean.find(Language.class, lang);
    if (language == null) {
        return badRequest("Unsupported language code");
    }
    user.setLanguage(language);
    user.update();
    return ok();
}
项目:exam    文件:ExaminationDateController.java   
@With(ExaminationDateSanitizer.class)
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result insertExaminationDate(Long eid) {
    Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound("exam not found");
    }
    LocalDate date = request().attrs().get(Attrs.DATE);
    ExaminationDate ed = new ExaminationDate();
    ed.setDate(date.toDate());
    ed.setExam(exam);
    ed.save();
    return ok(ed);
}