Search in sources :

Example 1 with DataIndex

use of com.github.noraui.data.DataIndex in project NoraUi by NoraUi.

the class MavenRunCounter method countWithoutModel.

private static void countWithoutModel(int nbStep, Counter result, List<DataIndex> indexData) throws TechnicalException {
    int failures = 0;
    int skipped = 0;
    for (int i = 1; i < Context.getDataInputProvider().getNbLines(); i++) {
        final List<Integer> index = new ArrayList<>();
        index.add(i);
        indexData.add(new DataIndex(i, index));
        final String resultColumn = Context.getDataInputProvider().readValue(Context.getDataInputProvider().getResultColumnName(), i);
        if (!"".equals(resultColumn)) {
            failures += 1;
            skipped += nbStep - (int) Double.parseDouble(resultColumn);
        }
    }
    result.setNbcas(indexData.size());
    result.setFailures(failures);
    result.setSkipped(skipped);
}
Also used : ArrayList(java.util.ArrayList) DataIndex(com.github.noraui.data.DataIndex)

Example 2 with DataIndex

use of com.github.noraui.data.DataIndex in project NoraUi by NoraUi.

the class MavenRunCounter method countWithModel.

private static void countWithModel(int nbStep, Counter result, List<DataIndex> indexData, Class<Model> model) throws TechnicalException {
    int failures = 0;
    int skipped = 0;
    final String[] headers = Context.getDataInputProvider().readLine(0, false);
    if (headers != null) {
        final Constructor<Model> modelConstructor = DataUtils.getModelConstructor(model, headers);
        final Map<String, ModelList> fusionedData = DataUtils.fusionProcessor(model, modelConstructor);
        int dataIndex = 0;
        for (final Entry<String, ModelList> e : fusionedData.entrySet()) {
            dataIndex++;
            indexData.add(new DataIndex(dataIndex, e.getValue().getIds()));
            for (int i = 0; i < e.getValue().getIds().size(); i++) {
                final Integer wid = e.getValue().getIds().get(i);
                final String resultColumn = Context.getDataInputProvider().readValue(Context.getDataInputProvider().getResultColumnName(), wid);
                if (!"".equals(resultColumn)) {
                    failures += 1;
                    skipped += nbStep - (int) Double.parseDouble(resultColumn);
                }
            }
        }
    } else {
        logger.error(Messages.getMessage(ScenarioInitiator.SCENARIO_INITIATOR_ERROR_EMPTY_FILE));
    }
    result.setNbcas(indexData.size());
    result.setFailures(failures);
    result.setSkipped(skipped);
}
Also used : ModelList(com.github.noraui.model.ModelList) Model(com.github.noraui.model.Model) DataIndex(com.github.noraui.data.DataIndex)

Example 3 with DataIndex

use of com.github.noraui.data.DataIndex in project NoraUi by NoraUi.

the class Context method initDataId.

private static void initDataId(String scenarioName) throws TechnicalException {
    final List<DataIndex> indexData = new ArrayList<>();
    try {
        Context.getDataInputProvider().prepare(scenarioName);
        final Class<Model> model = Context.getDataInputProvider().getModel(Context.getModelPackages());
        if (model != null) {
            final String[] headers = Context.getDataInputProvider().readLine(0, false);
            if (headers != null) {
                final Constructor<Model> modelConstructor = DataUtils.getModelConstructor(model, headers);
                final Map<String, ModelList> fusionedData = DataUtils.fusionProcessor(model, modelConstructor);
                int dataIndex = 0;
                for (final Entry<String, ModelList> e : fusionedData.entrySet()) {
                    dataIndex++;
                    indexData.add(new DataIndex(dataIndex, e.getValue().getIds()));
                }
            } else {
                logger.error(Messages.getMessage(ScenarioInitiator.SCENARIO_INITIATOR_ERROR_EMPTY_FILE));
            }
        } else {
            for (int i = 1; i < Context.getDataInputProvider().getNbLines(); i++) {
                final List<Integer> index = new ArrayList<>();
                index.add(i);
                indexData.add(new DataIndex(i, index));
            }
        }
        Context.getDataInputProvider().setIndexData(indexData);
    } catch (final Exception te) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE) + te.getMessage(), te);
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) ArrayList(java.util.ArrayList) InvalidFileFormatException(org.ini4j.InvalidFileFormatException) IOException(java.io.IOException) TechnicalException(com.github.noraui.exception.TechnicalException) ModelList(com.github.noraui.model.ModelList) DataIndex(com.github.noraui.data.DataIndex) Model(com.github.noraui.model.Model)

Aggregations

DataIndex (com.github.noraui.data.DataIndex)3 Model (com.github.noraui.model.Model)2 ModelList (com.github.noraui.model.ModelList)2 ArrayList (java.util.ArrayList)2 TechnicalException (com.github.noraui.exception.TechnicalException)1 IOException (java.io.IOException)1 InvalidFileFormatException (org.ini4j.InvalidFileFormatException)1