Search in sources :

Example 16 with ContextBase

use of org.apache.commons.chain.impl.ContextBase in project jackrabbit by apache.

the class Main method run.

public void run() throws Exception {
    String defaultFile = "jackrabbit-standalone.jar";
    URL location = Main.class.getProtectionDomain().getCodeSource().getLocation();
    if (location != null && "file".equals(location.getProtocol())) {
        File file = new File(location.getPath());
        if (file.isFile()) {
            defaultFile = location.getPath();
        }
    }
    File file = new File(command.getOptionValue("file", defaultFile));
    if (command.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar " + file.getName(), options, true);
    } else if (command.hasOption("notice")) {
        copyToOutput("/META-INF/NOTICE.txt");
    } else if (command.hasOption("license")) {
        copyToOutput("/META-INF/LICENSE.txt");
    } else if (command.hasOption("cli")) {
        System.setProperty("logback.configurationFile", "logback-cli.xml");
        String uri = command.getOptionValue("cli");
        Repository repository = JcrUtils.getRepository(uri);
        Context context = new ContextBase();
        CommandHelper.setRepository(context, repository, uri);
        try {
            Session session = repository.login();
            CommandHelper.setSession(context, session);
            CommandHelper.setCurrentNode(context, session.getRootNode());
        } catch (RepositoryException ignore) {
        // anonymous login not possible
        }
        new JcrClient(context).runInteractive();
        try {
            CommandHelper.getSession(context).logout();
        } catch (CommandException ignore) {
        // already logged out
        }
    } else {
        message("Welcome to Apache Jackrabbit!");
        message("-------------------------------");
        File repository = new File(command.getOptionValue("repo", "jackrabbit"));
        message("Using repository directory " + repository);
        repository.mkdirs();
        File tmp = new File(repository, "tmp");
        tmp.mkdir();
        File log = new File(repository, "log");
        log.mkdir();
        message("Writing log messages to " + log);
        prepareServerLog(log);
        if (command.hasOption("backup")) {
            backup(repository);
        } else {
            message("Starting the server...");
            prepareWebapp(file, repository, tmp);
            accessLog.setHandler(webapp);
            prepareAccessLog(log);
            server.setHandler(accessLog);
            prepareConnector();
            server.addConnector(connector);
            prepareShutdown();
            try {
                server.start();
                String host = connector.getHost();
                if (host == null) {
                    host = "localhost";
                }
                message("Apache Jackrabbit is now running at " + "http://" + host + ":" + connector.getPort() + "/");
            } catch (Throwable t) {
                System.err.println("Unable to start the server: " + t.getMessage());
                System.exit(1);
            }
        }
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Context(org.apache.commons.chain.Context) Repository(javax.jcr.Repository) RepositoryException(javax.jcr.RepositoryException) CommandException(org.apache.jackrabbit.standalone.cli.CommandException) File(java.io.File) URL(java.net.URL) JcrClient(org.apache.jackrabbit.standalone.cli.JcrClient) ContextBase(org.apache.commons.chain.impl.ContextBase) Session(javax.jcr.Session)

Example 17 with ContextBase

use of org.apache.commons.chain.impl.ContextBase in project bamboobsc by billchen198318.

the class PerformanceScoreChainUtils method getContext.

public static Context getContext(String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    Context context = new ContextBase();
    context.put("visionOid", visionOid);
    context.put("startDate", startDate);
    context.put("endDate", endDate);
    context.put("startYearDate", startYearDate);
    context.put("endYearDate", endYearDate);
    context.put("frequency", frequency);
    context.put("dataFor", dataFor);
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    context.put("account", "");
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
        OrganizationVO organization = new OrganizationVO();
        organization.setOid(measureDataOrganizationOid);
        DefaultResult<OrganizationVO> result = organizationService.findObjectByOid(organization);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        organization = result.getValue();
        context.put("orgId", organization.getOrgId());
    }
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
        EmployeeVO employee = new EmployeeVO();
        employee.setOid(measureDataEmployeeOid);
        DefaultResult<EmployeeVO> result = employeeService.findObjectByOid(employee);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        employee = result.getValue();
        context.put("empId", employee.getEmpId());
        context.put("account", employee.getAccount());
    }
    return context;
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 18 with ContextBase

use of org.apache.commons.chain.impl.ContextBase in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method getChainContext.

@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
    Context context = new ContextBase();
    context.put("visionOid", this.getFields().get("visionOid"));
    context.put("startDate", this.getFields().get("startDate"));
    context.put("endDate", this.getFields().get("endDate"));
    context.put("startYearDate", this.getFields().get("startYearDate"));
    context.put("endYearDate", this.getFields().get("endYearDate"));
    context.put("frequency", this.getFields().get("frequency"));
    context.put("dataFor", this.getFields().get("dataFor"));
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    context.put("account", "");
    context.put("pieCanvasToData", SimpleUtils.deHex(this.defaultString(this.getFields().get("pieCanvasToData"))));
    context.put("barCanvasToData", SimpleUtils.deHex(this.defaultString(this.getFields().get("barCanvasToData"))));
    context.put("uploadSignatureOid", this.getFields().get("uploadSignatureOid"));
    context.put("ngVer", YesNo.NO);
    if ("Y".equals(this.getFields().get("ngVer"))) {
        // 有 javascript click 事件 kpi-report-body-ng.ftl 版本
        context.put("ngVer", YesNo.YES);
    }
    if (!this.isNoSelectId(this.getFields().get("measureDataOrganizationOid"))) {
        OrganizationVO organization = new OrganizationVO();
        organization.setOid(this.getFields().get("measureDataOrganizationOid"));
        DefaultResult<OrganizationVO> result = this.organizationService.findObjectByOid(organization);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        organization = result.getValue();
        context.put("orgId", organization.getOrgId());
    }
    if (!this.isNoSelectId(this.getFields().get("measureDataEmployeeOid"))) {
        EmployeeVO employee = new EmployeeVO();
        employee.setOid(this.getFields().get("measureDataEmployeeOid"));
        DefaultResult<EmployeeVO> result = this.employeeService.findObjectByOid(employee);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        employee = result.getValue();
        context.put("empId", employee.getEmpId());
        context.put("account", employee.getAccount());
    }
    this.setContextForSingleObject(context);
    return context;
}
Also used : Context(org.apache.commons.chain.Context) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 19 with ContextBase

use of org.apache.commons.chain.impl.ContextBase in project bamboobsc by billchen198318.

the class KpiTreeJsonAction method loadTreeItems.

@SuppressWarnings("unchecked")
private void loadTreeItems() throws ServiceException, Exception {
    Context context = new ContextBase();
    context.put("http", this.getHttpServletRequest().getScheme() + "://");
    SimpleChain chain = new SimpleChain();
    ChainResultObj result = chain.getResultFromResource("kpiTreeItemsChain", context);
    this.message = super.defaultString(result.getMessage());
    if (result.getValue() != null && result.getValue() instanceof List) {
        this.items = (List<Map<String, Object>>) result.getValue();
    }
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) List(java.util.List) Map(java.util.Map) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 20 with ContextBase

use of org.apache.commons.chain.impl.ContextBase in project bamboobsc by billchen198318.

the class PersonalReportContentQueryAction method getChainContext.

@SuppressWarnings("unchecked")
private Context getChainContext() throws Exception {
    Context context = new ContextBase();
    context.put("visionOid", this.getFields().get("visionOid"));
    context.put("frequency", this.getFields().get("frequency"));
    context.put("startYearDate", this.getFields().get("year"));
    context.put("endYearDate", this.getFields().get("year"));
    context.put("dateType", this.getFields().get("dateType"));
    context.put("dataFor", BscConstants.MEASURE_DATA_FOR_EMPLOYEE);
    EmployeeVO employee = new EmployeeVO();
    employee.setOid(this.getFields().get("employeeOid"));
    DefaultResult<EmployeeVO> result = this.employeeService.findObjectByOid(employee);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    employee = result.getValue();
    context.put("empId", employee.getEmpId());
    context.put("account", employee.getAccount());
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("uploadSignatureOid", this.getFields().get("uploadSignatureOid"));
    return context;
}
Also used : Context(org.apache.commons.chain.Context) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ContextBase(org.apache.commons.chain.impl.ContextBase)

Aggregations

Context (org.apache.commons.chain.Context)22 ContextBase (org.apache.commons.chain.impl.ContextBase)22 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)8 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)8 Map (java.util.Map)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 ArrayList (java.util.ArrayList)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 AppContext (com.netsteadfast.greenstep.base.AppContext)3 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)3 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)3 LinkedHashMap (java.util.LinkedHashMap)3 LinkedList (java.util.LinkedList)3 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 HashMap (java.util.HashMap)2 List (java.util.List)2 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 TimeSeriesAnalysisResult (com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult)1 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)1 BbPdcaKpis (com.netsteadfast.greenstep.po.hbm.BbPdcaKpis)1