All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kie.kogito.app.DecisionModelResourcesProvider Maven / Gradle / Ivy

There is a newer version: 2.44.0.Alpha
Show newest version
/*
 * Copyright 2021 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kie.kogito.app;

@org.springframework.stereotype.Component()
public class DecisionModelResourcesProvider implements org.kie.kogito.decision.DecisionModelResourcesProvider {

    // See https://issues.redhat.com/browse/KOGITO-3330
    private static java.io.InputStreamReader readResource(java.io.InputStream stream) {
        if (org.kie.kogito.internal.RuntimeEnvironment.isJdk()) {
            return new java.io.InputStreamReader(stream);
        }
        try {
            byte[] bytes = org.drools.util.IoUtils.readBytesFromInputStream(stream);
            java.io.ByteArrayInputStream byteArrayInputStream = new java.io.ByteArrayInputStream(bytes);
            return new java.io.InputStreamReader(byteArrayInputStream);
        } catch (java.io.IOException e) {
            throw new java.io.UncheckedIOException(e);
        }
    }

    private final static java.util.List resources = getResources();

    @Override
    public java.util.List get() {
        return this.resources;
    }

    private final static java.util.List getResources() {
        java.util.List resourcePaths = new java.util.ArrayList<>();
        resourcePaths.add(new org.kie.kogito.dmn.DefaultDecisionModelResource(new org.kie.kogito.KogitoGAV("org.kie.kogito", "integration-tests-trusty-service-springboot", "1.39.0.Final"), "https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF", "Traffic Violation", new org.kie.kogito.decision.DecisionModelMetadata("http://www.omg.org/spec/DMN/20180521/MODEL/"), readResource(Application.class.getResourceAsStream("/TrafficViolation.dmn"))));
        return resourcePaths;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy