Search in sources :

Example 1 with CommandOption

use of org.apache.nifi.toolkit.cli.impl.command.CommandOption in project nifi by apache.

the class BucketsResult method createReferenceResolver.

@Override
public ReferenceResolver createReferenceResolver(final Context context) {
    final Map<Integer, Bucket> backRefs = new HashMap<>();
    final AtomicInteger position = new AtomicInteger(0);
    buckets.forEach(b -> backRefs.put(position.incrementAndGet(), b));
    return new ReferenceResolver() {

        @Override
        public ResolvedReference resolve(final CommandOption option, final Integer position) {
            final Bucket bucket = backRefs.get(position);
            if (bucket != null) {
                return new ResolvedReference(option, position, bucket.getName(), bucket.getIdentifier());
            } else {
                return null;
            }
        }

        @Override
        public boolean isEmpty() {
            return backRefs.isEmpty();
        }
    };
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResolvedReference(org.apache.nifi.toolkit.cli.api.ResolvedReference) CommandOption(org.apache.nifi.toolkit.cli.impl.command.CommandOption) Bucket(org.apache.nifi.registry.bucket.Bucket) HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReferenceResolver(org.apache.nifi.toolkit.cli.api.ReferenceResolver)

Example 2 with CommandOption

use of org.apache.nifi.toolkit.cli.impl.command.CommandOption in project nifi by apache.

the class ProcessGroupsResult method createReferenceResolver.

@Override
public ReferenceResolver createReferenceResolver(final Context context) {
    final Map<Integer, ProcessGroupDTO> backRefs = new HashMap<>();
    final AtomicInteger position = new AtomicInteger(0);
    processGroups.forEach(p -> backRefs.put(position.incrementAndGet(), p));
    return new ReferenceResolver() {

        @Override
        public ResolvedReference resolve(final CommandOption option, final Integer position) {
            final ProcessGroupDTO pg = backRefs.get(position);
            if (pg != null) {
                return new ResolvedReference(option, position, pg.getName(), pg.getId());
            } else {
                return null;
            }
        }

        @Override
        public boolean isEmpty() {
            return backRefs.isEmpty();
        }
    };
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResolvedReference(org.apache.nifi.toolkit.cli.api.ResolvedReference) CommandOption(org.apache.nifi.toolkit.cli.impl.command.CommandOption) HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) ReferenceResolver(org.apache.nifi.toolkit.cli.api.ReferenceResolver)

Example 3 with CommandOption

use of org.apache.nifi.toolkit.cli.impl.command.CommandOption in project nifi by apache.

the class VersionedFlowsResult method createReferenceResolver.

@Override
public ReferenceResolver createReferenceResolver(final Context context) {
    final Map<Integer, VersionedFlow> backRefs = new HashMap<>();
    final AtomicInteger position = new AtomicInteger(0);
    versionedFlows.forEach(f -> backRefs.put(position.incrementAndGet(), f));
    return new ReferenceResolver() {

        @Override
        public ResolvedReference resolve(final CommandOption option, final Integer position) {
            final VersionedFlow versionedFlow = backRefs.get(position);
            if (versionedFlow != null) {
                if (option != null && option == CommandOption.BUCKET_ID) {
                    return new ResolvedReference(option, position, versionedFlow.getBucketName(), versionedFlow.getBucketIdentifier());
                } else {
                    return new ResolvedReference(option, position, versionedFlow.getName(), versionedFlow.getIdentifier());
                }
            } else {
                return null;
            }
        }

        @Override
        public boolean isEmpty() {
            return backRefs.isEmpty();
        }
    };
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResolvedReference(org.apache.nifi.toolkit.cli.api.ResolvedReference) CommandOption(org.apache.nifi.toolkit.cli.impl.command.CommandOption) HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) ReferenceResolver(org.apache.nifi.toolkit.cli.api.ReferenceResolver)

Aggregations

HashMap (java.util.HashMap)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ReferenceResolver (org.apache.nifi.toolkit.cli.api.ReferenceResolver)3 ResolvedReference (org.apache.nifi.toolkit.cli.api.ResolvedReference)3 CommandOption (org.apache.nifi.toolkit.cli.impl.command.CommandOption)3 Bucket (org.apache.nifi.registry.bucket.Bucket)1 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)1 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)1