Examples of DirectFileOutputDescription


Examples of com.asakusafw.vocabulary.directio.DirectFileOutputDescription

        return valid;
    }

    private boolean validateOutput(OutputDescription output) {
        boolean valid = true;
        DirectFileOutputDescription desc = extract(output);
        valid &= checkBasePath(desc.getClass(), desc.getBasePath(), "出力ベースパス");
        DataClass dataType = getEnvironment().getDataClasses().load(desc.getModelType());
        String pattern = desc.getResourcePattern();
        List<CompiledResourcePattern> compiledPattern;
        try {
            compiledPattern = OutputPattern.compileResourcePattern(pattern, dataType);
        } catch (IllegalArgumentException e) {
            getEnvironment().error(
                    "出力リソース名のパターンが不正です ({1}) [{0}]",
                    e.getMessage(),
                    desc.getClass().getName());
            valid = false;
            compiledPattern = Collections.emptyList();
        }

        for (String patternString : desc.getDeletePatterns()) {
            try {
                FilePattern.compile(patternString);
            } catch (IllegalArgumentException e) {
                getEnvironment().error(
                        "削除するリソース名のパターン(\"{2}\")が不正です ({1}) [{0}]",
                        e.getMessage(),
                        desc.getClass().getName(),
                        patternString);
                valid = false;
            }
        }

        List<String> orders = desc.getOrder();
        try {
            OutputPattern.compileOrder(orders, dataType);
        } catch (IllegalArgumentException e) {
            getEnvironment().error(
                    "出力順序の指定が不正です ({1}) [{0}]",
                    e.getMessage(),
                    desc.getClass().getName());
            valid = false;
        }

        Set<OutputPattern.SourceKind> kinds = pickSourceKinds(compiledPattern);
        if (kinds.contains(OutputPattern.SourceKind.ENVIRONMENT)) {
            if (kinds.contains(OutputPattern.SourceKind.PROPERTY)) {
                getEnvironment().error(
                        "出力リソース名にワイルドカードを含む場合、プロパティ ('{'name'}') は指定できません"
                        + " ({1}.{2}()): {0}",
                        pattern,
                        desc.getClass().getName(),
                        METHOD_RESOURCE_PATTERN);
                valid = false;
            }
            if (kinds.contains(OutputPattern.SourceKind.RANDOM)) {
                getEnvironment().error(
                        "出力リソース名にワイルドカードを含む場合、ランダム ([m..n]) は指定できません"
                        + " ({1}.{2}()): {0}",
                        pattern,
                        desc.getClass().getName(),
                        METHOD_RESOURCE_PATTERN);
                valid = false;
            }
            if (orders.isEmpty() == false) {
                getEnvironment().error(
                        "出力リソース名にワイルドカードを含む場合、出力順序は指定できません"
                        + " ({1}.{2}()): {0}",
                        pattern,
                        desc.getClass().getName(),
                        METHOD_ORDER);
                valid = false;
            }
        }

        valid &= validateFormat(desc.getClass(), desc.getModelType(), desc.getFormat());
        return valid;
    }
View Full Code Here

Examples of com.asakusafw.vocabulary.directio.DirectFileOutputDescription

            String path = normalizePath(desc.getBasePath());
            inputPaths.put(path, input);
        }
        TreeMap<String, OutputDescription> outputPaths = new TreeMap<String, OutputDescription>();
        for (OutputDescription output : outputs) {
            DirectFileOutputDescription desc = extract(output);
            String path = normalizePath(desc.getBasePath());
            for (Map.Entry<String, InputDescription> entry : inputPaths.tailMap(path, true).entrySet()) {
                if (entry.getKey().startsWith(path) == false) {
                    break;
                }
                DirectFileInputDescription other = extract(entry.getValue());
                getEnvironment().error(
                        "入出力のベースパスが衝突しています: {0}[{1}] -> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            }
            if (outputPaths.containsKey(path)) {
                DirectFileOutputDescription other = extract(outputPaths.get(path));
                getEnvironment().error(
                        "2つの出力のベースパスが重複しています: {0}[{1}] <-> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            } else {
                outputPaths.put(path, output);
            }
        }
        for (Map.Entry<String, OutputDescription> base : outputPaths.entrySet()) {
            String path = base.getKey();
            DirectFileOutputDescription desc = extract(base.getValue());
            for (Map.Entry<String, OutputDescription> entry : outputPaths.tailMap(path, false).entrySet()) {
                if (entry.getKey().startsWith(path) == false) {
                    break;
                }
                DirectFileOutputDescription other = extract(entry.getValue());
                getEnvironment().error(
                        "2つの出力のベースパスが衝突しています: {0}[{1}] -> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            }
        }
        return valid;
    }
View Full Code Here

Examples of com.asakusafw.vocabulary.directio.DirectFileOutputDescription

        ModelFactory f = getEnvironment().getModelFactory();
        NamingClassEmitter namingEmitter = new NamingClassEmitter(getEnvironment(), MODULE_NAME);
        OrderingClassEmitter orderingEmitter = new OrderingClassEmitter(getEnvironment(), MODULE_NAME);
        List<Slot> slots = Lists.create();
        for (Output output : context.getOutputs()) {
            DirectFileOutputDescription desc = extract(output.getDescription());
            DataClass dataType = getEnvironment().getDataClasses().load(desc.getModelType());
            List<CompiledResourcePattern> namingInfo =
                OutputPattern.compileResourcePattern(desc.getResourcePattern(), dataType);
            Set<OutputPattern.SourceKind> kinds = pickSourceKinds(namingInfo);
            if (kinds.contains(OutputPattern.SourceKind.ENVIRONMENT)) {
                assert kinds.contains(OutputPattern.SourceKind.PROPERTY) == false;
                assert kinds.contains(OutputPattern.SourceKind.RANDOM) == false;
                assert desc.getOrder().isEmpty();
                String outputName = output.getDescription().getName();
                Slot slot = new Slot(
                        outputName,
                        output.getSources(),
                        Models.toName(f, desc.getModelType().getName()),
                        desc.getBasePath(),
                        desc.getResourcePattern(),
                        Models.toName(f, desc.getFormat().getName()),
                        null,
                        null,
                        desc.getDeletePatterns());
                slots.add(slot);
            } else {
                List<CompiledOrder> orderingInfo = OutputPattern.compileOrder(desc.getOrder(), dataType);
                String outputName = output.getDescription().getName();
                Name naming = namingEmitter.emit(outputName, slots.size() + 1, dataType, namingInfo);
                Name ordering = orderingEmitter.emit(outputName, slots.size() + 1, dataType, orderingInfo);
                Slot slot = new Slot(
                        outputName,
                        output.getSources(),
                        Models.toName(f, desc.getModelType().getName()),
                        desc.getBasePath(),
                        desc.getResourcePattern(),
                        Models.toName(f, desc.getFormat().getName()),
                        naming,
                        ordering,
                        desc.getDeletePatterns());
                slots.add(slot);
            }
        }
        if (slots.isEmpty()) {
            return Collections.emptyList();
View Full Code Here

Examples of com.asakusafw.vocabulary.directio.DirectFileOutputDescription

        Class<? extends DirectFileOutputDescription> aClass = generate(description);
        assertThat(DirectFileOutputDescription.class.isAssignableFrom(aClass), is(true));
        assertThat(Modifier.isAbstract(aClass.getModifiers()), is(false));

        DirectFileOutputDescription object = aClass.newInstance();
        assertThat(object.getModelType(), is((Object) MockData.class));
        assertThat(object.getBasePath(), is("base-path"));
        assertThat(object.getResourcePattern(), is("*"));
        assertThat(object.getOrder(), is(Arrays.asList("something1", "something2")));
        assertThat(object.getDeletePatterns(), is(Arrays.asList("delete1-*", "delete2-*")));
        assertThat(object.getFormat(), is((Object) MockDataFormat.class));
    }
View Full Code Here

Examples of com.asakusafw.vocabulary.directio.DirectFileOutputDescription

        Class<? extends DirectFileOutputDescription> aClass = generate(description);
        assertThat(DirectFileOutputDescription.class.isAssignableFrom(aClass), is(true));
        assertThat(Modifier.isAbstract(aClass.getModifiers()), is(false));

        DirectFileOutputDescription object = aClass.newInstance();
        assertThat(object.getModelType(), is((Object) MockData.class));
        assertThat(object.getBasePath(), is("base-path"));
        assertThat(object.getResourcePattern(), is("*"));
        assertThat(object.getOrder(), is(Arrays.<String>asList()));
        assertThat(object.getDeletePatterns(), is(Arrays.<String>asList()));
        assertThat(object.getFormat(), is((Object) MockDataFormat.class));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.