Search in sources :

Example 1 with Icon

use of org.talend.sdk.component.api.component.Icon in project component-runtime by Talend.

the class ComponentValidator method run.

@Override
public void run() {
    final AnnotationFinder finder = newFinder();
    final List<Class<?>> components = componentMarkers().flatMap(a -> finder.findAnnotatedClasses(a).stream()).collect(toList());
    components.forEach(c -> log.debug("Found component: " + c));
    final Set<String> errors = new HashSet<>();
    if (configuration.isValidateFamily()) {
        // todo: better fix is to get the package with @Components then check it has an icon
        // but it should be enough for now
        components.forEach(c -> {
            try {
                findPackageOrFail(c, Icon.class);
            } catch (final IllegalArgumentException iae) {
                errors.add(iae.getMessage());
            }
        });
    }
    if (configuration.isValidateSerializable()) {
        final Collection<Class<?>> copy = new ArrayList<>(components);
        copy.removeIf(this::isSerializable);
        errors.addAll(copy.stream().map(c -> c + " is not Serializable").collect(toList()));
    }
    if (configuration.isValidateInternationalization()) {
        validateInternationalization(finder, components, errors);
    }
    if (configuration.isValidateHttpClient()) {
        validateHttpClient(finder, errors);
    }
    if (configuration.isValidateModel()) {
        validateModel(finder, components, errors);
    }
    if (configuration.isValidateMetadata()) {
        validateMetadata(components, errors);
    }
    if (configuration.isValidateDataStore()) {
        validateDataStore(finder, errors);
    }
    if (configuration.isValidateDataSet()) {
        validateDataSet(finder, errors);
    }
    if (configuration.isValidateActions()) {
        validateActions(finder, errors);
    }
    if (configuration.isValidateDocumentation()) {
        validateDocumentation(finder, components, errors);
    }
    if (configuration.isValidateLayout()) {
        validateLayout(finder, components, errors);
    }
    if (!errors.isEmpty()) {
        errors.forEach(log::error);
        throw new IllegalStateException("Some error were detected:" + errors.stream().collect(joining("\n- ", "\n- ", "")));
    }
}
Also used : AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) Version(org.talend.sdk.component.api.component.Version) Internationalized(org.talend.sdk.component.api.internationalization.Internationalized) HealthCheck(org.talend.sdk.component.api.service.healthcheck.HealthCheck) Collectors.toMap(java.util.stream.Collectors.toMap) ARRAY(org.talend.sdk.component.runtime.manager.ParameterMeta.Type.ARRAY) Map(java.util.Map) DynamicValues(org.talend.sdk.component.api.service.completion.DynamicValues) Method(java.lang.reflect.Method) Collectors.toSet(java.util.stream.Collectors.toSet) ParameterMeta(org.talend.sdk.component.runtime.manager.ParameterMeta) AsyncValidation(org.talend.sdk.component.api.service.asyncvalidation.AsyncValidation) ENUM(org.talend.sdk.component.runtime.manager.ParameterMeta.Type.ENUM) Collection(java.util.Collection) Set(java.util.Set) Collectors.joining(java.util.stream.Collectors.joining) Serializable(java.io.Serializable) DataSet(org.talend.sdk.component.api.configuration.type.DataSet) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) Documentation(org.talend.sdk.component.api.meta.Documentation) Proposable(org.talend.sdk.component.api.configuration.action.Proposable) Modifier(java.lang.reflect.Modifier) Function.identity(java.util.function.Function.identity) Service(org.talend.sdk.component.api.service.Service) Constructors.findConstructor(org.talend.sdk.component.runtime.manager.reflect.Constructors.findConstructor) Stream.empty(java.util.stream.Stream.empty) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) DiscoverSchema(org.talend.sdk.component.api.service.schema.DiscoverSchema) Icon(org.talend.sdk.component.api.component.Icon) Option(org.talend.sdk.component.api.configuration.Option) ModelListener(org.talend.sdk.component.runtime.visitor.ModelListener) DataStore(org.talend.sdk.component.api.configuration.type.DataStore) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ResourceBundle(java.util.ResourceBundle) ParameterModelService(org.talend.sdk.component.runtime.manager.reflect.ParameterModelService) Structure(org.talend.sdk.component.api.configuration.ui.widget.Structure) Stream.concat(java.util.stream.Stream.concat) Request(org.talend.sdk.component.api.service.http.Request) OBJECT(org.talend.sdk.component.runtime.manager.ParameterMeta.Type.OBJECT) Optional.ofNullable(java.util.Optional.ofNullable) Stream.of(java.util.stream.Stream.of) ModelVisitor(org.talend.sdk.component.runtime.visitor.ModelVisitor) Field(java.lang.reflect.Field) File(java.io.File) HttpClientFactoryImpl(org.talend.sdk.component.runtime.manager.service.HttpClientFactoryImpl) Collectors.toList(java.util.stream.Collectors.toList) AbstractMap(java.util.AbstractMap) Checkable(org.talend.sdk.component.api.configuration.action.Checkable) ParameterizedType(java.lang.reflect.ParameterizedType) Data(lombok.Data) ActionType(org.talend.sdk.component.api.service.ActionType) ArrayList(java.util.ArrayList) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) HashSet(java.util.HashSet)

Aggregations

File (java.io.File)1 Serializable (java.io.Serializable)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Modifier (java.lang.reflect.Modifier)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional.ofNullable (java.util.Optional.ofNullable)1 ResourceBundle (java.util.ResourceBundle)1 Set (java.util.Set)1 Function.identity (java.util.function.Function.identity)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toList (java.util.stream.Collectors.toList)1