Package com.sun.enterprise.util

Examples of com.sun.enterprise.util.ColumnFormatter


        // Force longOpt if output option is specified
        if (outputOpts != null) {
            longOpt = true;
        }
        List<ColumnInfo> cols = null;
        ColumnFormatter colfm = null;
        if (longOpt) {
            cols = getColumnInfo(targetType);
            if (!isOutputOptsValid(cols, outputOpts)) {
                String collist = arrayToString(getColumnHeadings(cols));
                String msg = localStrings.getLocalString(GenericCrudCommand.class,
                    "GenericListCommand.invalidOutputOpts",
                    "Invalid output option. Choose from the following columns: {0}",
                    collist);
                report.failure(logger, msg);
                return;
            }
            cols = filterColumns(cols, outputOpts);
            // sort the columns based on column ordering
            Collections.sort(cols, new Comparator<ColumnInfo>() {
                @Override
                public int compare(ColumnInfo o1, ColumnInfo o2) {
                    return Integer.valueOf(o1.order).compareTo(Integer.valueOf(o2.order));
                }
            });
            colfm = headerOpt ? new ColumnFormatter(getColumnHeadings(cols)) : new ColumnFormatter();
        }
      
        List<Map> list = new ArrayList<Map>();
        Properties props = report.getExtraProperties();
        if (props == null) {
            props = new Properties();
            report.setExtraProperties(props);
        }
       
        try {      
            List<ConfigBeanProxy> children = (List<ConfigBeanProxy>) targetMethod.invoke(parentBean);
            for (ConfigBeanProxy child : children) {
                if (name != null && !name.equals(Dom.unwrap(child).getKey())) {
                    continue;
                }
                Map<String,String> map = new HashMap<String,String>();
                if (longOpt) {
                    String data[] = getColumnData(child, cols);
                    colfm.addRow(data);
                    for (int i = 0; i < data.length; i++) {
                        map.put(cols.get(i).xmlName, data[i]);
                    }
                } else {
                    Dom childDom = Dom.unwrap(child);
                    String key = childDom.getKey();
                    if (key==null) {
                        String msg = localStrings.getLocalString(GenericCrudCommand.class,
                                "GenericListCommand.element_has_no_key",
                                "The element {0} has no key attribute",
                                targetType);
                        report.failure(logger, msg);
                        return;
                    }
                    report.addSubActionsReport().setMessage(key);
                    map.put("key", key);
                }
                list.add(map);
            }
            if (longOpt) {
                report.appendMessage(colfm.toString());
            }
            if (!list.isEmpty()) {
                props.put(elementName(Dom.unwrap(parentBean).document, parentType, targetType), list);
            }
        } catch (Exception e) {
View Full Code Here


        map.put(MAX_QUEUE_SIZE, helper.getMaxQueueSize());
        map.put(DATA_SOURCE_NAME, helper.getDataSourceName());
        map.put(MAX_DATA_RETENTION_TIME, helper.getMaxRetentionTime());
        extraProps.put("list-batch-runtime-configuration", map);

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        Object[] data = new Object[getOutputHeaders().length];
        for (int index=0; index<getOutputHeaders().length; index++) {
            switch (getOutputHeaders()[index]) {
                case MAX_THREAD_POOL_SIZE:
                    data[index] = helper.getMaxThreadPoolSize();
                    break;
                case MIN_THREAD_POOL_SIZE:
                    data[index] = helper.getMinThreadPoolSize();
                    break;
                case MAX_IDLE_THREAD_TIMEOUT:
                    data[index] = helper.getMaxIdleThreadTimeout();
                    break;
                case MAX_QUEUE_SIZE:
                    data[index] = helper.getMaxQueueSize();
                    break;
                case DATA_SOURCE_NAME:
                    data[index] = helper.getDataSourceName();
                    break;
                case MAX_DATA_RETENTION_TIME:
                    data[index] = helper.getMaxRetentionTime();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
        }
        columnFormatter.addRow(data);
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

    String executionId;

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps) {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        if (isSimpleMode()) {
            extraProps.put("simple-mode", true);
            extraProps.put("list-batch-jobs", findSimpleJobInfo(columnFormatter));
        } else {
            extraProps.put("simple-mode", false);
            for (JobExecution je : findJobExecutions()) {
                handleJob(je, columnFormatter);
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

                    data = je.getEndTime();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter();
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[] {e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString());
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
            jobInfo.put(getOutputHeaders()[index], data);
View Full Code Here

        map.put(DATA_SOURCE_NAME, batchRuntimeConfiguration.getDataSourceLookupName());
        map.put(EXECUTOR_SERVICE_NAME, batchRuntimeConfiguration.getExecutorServiceLookupName());
        extraProps.put("listBatchRuntimeConfiguration", map);

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        Object[] data = new Object[getOutputHeaders().length];
        for (int index=0; index<getOutputHeaders().length; index++) {
            switch (getOutputHeaders()[index]) {
                case DATA_SOURCE_NAME:
                    data[index] = batchRuntimeConfiguration.getDataSourceLookupName();
                    break;
                case EXECUTOR_SERVICE_NAME:
                    data[index] = batchRuntimeConfiguration.getExecutorServiceLookupName();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
        }
        columnFormatter.addRow(data);
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobExecutions", jobExecutions);
        if (executionId != null) {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            JobExecution je = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (instanceId != null) {
                JobInstance ji = jobOperator.getJobInstance(Long.valueOf(executionId));
                if (ji.getInstanceId() != Long.valueOf(instanceId)) {
                    throw new RuntimeException("executionid " + executionId
                    + " is not associated with the specified instanceid (" + instanceId + ")"
                    + "; did you mean " + ji.getInstanceId() + " ?");
                }
            }
            jobExecutions.add(handleJob(je, columnFormatter));
        } else if (instanceId != null) {
            for (JobExecution je : getJobExecutionForInstance(Long.valueOf(instanceId))) {
                jobExecutions.add(handleJob(je, columnFormatter));
            }
        } else {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            Set<String> jobNames = jobOperator.getJobNames();
            if (jobNames != null) {
                for (String jn : jobOperator.getJobNames()) {
                    List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
                    if (exe != null) {
                        for (JobInstance ji : exe) {
                            for (JobExecution je : jobOperator.getJobExecutions(ji)) {
                                jobExecutions.add(handleJob(jobOperator.getJobExecution(je.getExecutionId()), columnFormatter));
                            }
                        }
                    }
                }
            }
        }
        if (jobExecutions.size() > 0) {
            context.getActionReport().setMessage(columnFormatter.toString());
        } else {
            throw new RuntimeException("No Job Executions found");
        }

    }
View Full Code Here

                    cfData[index] = je.getEndTime().toString();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                case STEP_COUNT:
                    long exeId = executionId == null ? je.getExecutionId() : Long.valueOf(executionId);
                    data = jobOperator.getStepExecutions(exeId) == null
                        ? 0 : jobOperator.getStepExecutions(exeId).size();
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobSteps", jobExecutions);
        for (StepExecution je : findStepExecutions()) {
            jobExecutions.add(handleJob(je, columnFormatter));
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

                    break;
                case STEP_METRICS:
                    stepMetricsIndex = index;
                    Map<String, Long> metricMap = new HashMap<>();
                    if (stepExecution.getMetrics() != null) {
                        ColumnFormatter cf = new ColumnFormatter(new String[]{"METRICNAME", "VALUE"});
                        for (Metric metric : stepExecution.getMetrics()) {
                            metricMap.put(metric.getType().name(), metric.getValue());
                            cf.addRow(new Object[] {metric.getType().name(), metric.getValue()});
                        }
                        st = new StringTokenizer(cf.toString(), "\n");
                    }
                    data = metricMap;
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        if (isSimpleMode()) {
            extraProps.put("simpleMode", true);
            extraProps.put("listBatchJobs", findSimpleJobInfo(columnFormatter));
        } else {
            extraProps.put("simpleMode", false);
            List<Map<String, Object>> jobExecutions = new ArrayList<>();
            extraProps.put("listBatchJobs", jobExecutions);
            for (JobExecution je : findJobExecutions()) {
                jobExecutions.add(handleJob(je, columnFormatter));
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.util.ColumnFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.