Search in sources :

Example 16 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project hedera-services by hashgraph.

the class JKeyUtils method genSampleComplexKey.

/**
 * Generates a complex key of given depth with a mix of basic key, threshold key and key list.
 *
 * @param depth
 * 		of the generated key
 * @return generated key
 */
public static Key genSampleComplexKey(final int depth, final Map<String, PrivateKey> pubKey2privKeyMap) {
    Key rv;
    final int numKeys = 3;
    final int threshold = 2;
    if (depth == 1) {
        rv = genSingleEd25519Key(pubKey2privKeyMap);
        // verify the size
        final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
        assertEquals(1, size);
    } else if (depth == 2) {
        final List<Key> keys = new ArrayList<>();
        keys.add(genSingleEd25519Key(pubKey2privKeyMap));
        keys.add(genSingleECDSASecp256k1Key(pubKey2privKeyMap));
        keys.add(genThresholdKeyInstance(numKeys, threshold, pubKey2privKeyMap));
        keys.add(genKeyListInstance(numKeys, pubKey2privKeyMap));
        rv = genKeyList(keys);
        // verify the size
        final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
        assertEquals(2 + numKeys * 2, size);
    } else {
        throw new NotImplementedException("Not implemented yet.");
    }
    return rv;
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) AtomicCounter(com.hedera.services.legacy.proto.utils.AtomicCounter) ArrayList(java.util.ArrayList) List(java.util.List) KeyList(com.hederahashgraph.api.proto.java.KeyList) Key(com.hederahashgraph.api.proto.java.Key) PrivateKey(java.security.PrivateKey) ThresholdKey(com.hederahashgraph.api.proto.java.ThresholdKey) EdDSAPublicKey(net.i2p.crypto.eddsa.EdDSAPublicKey)

Example 17 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project tiamat by entur.

the class StopPlaceImportHandler method handleStops.

public void handleStops(SiteFrame netexSiteFrame, ImportParams importParams, AtomicInteger stopPlacesCreatedMatchedOrUpdated, SiteFrame responseSiteframe) {
    if (publicationDeliveryHelper.hasStops(netexSiteFrame)) {
        List<StopPlace> tiamatStops = netexMapper.mapStopsToTiamatModel(netexSiteFrame.getStopPlaces().getStopPlace());
        tiamatStops = stopPlaceTypeFilter.filter(tiamatStops, importParams.allowOnlyStopTypes);
        if (importParams.ignoreStopTypes != null && !importParams.ignoreStopTypes.isEmpty()) {
            tiamatStops = stopPlaceTypeFilter.filter(tiamatStops, importParams.ignoreStopTypes, true);
        }
        boolean isImportTypeIdMatch = importParams.importType != null && importParams.importType.equals(ImportType.ID_MATCH);
        if (!isImportTypeIdMatch) {
            logger.info("Running stop place pre steps");
            tiamatStops = stopPlacePreSteps.run(tiamatStops);
        }
        int numberOfStopBeforeFiltering = tiamatStops.size();
        logger.info("About to filter {} stops based on topographic references: {}", tiamatStops.size(), importParams.targetTopographicPlaces);
        tiamatStops = zoneTopographicPlaceFilter.filterByTopographicPlaceMatch(importParams.targetTopographicPlaces, tiamatStops);
        logger.info("Got {} stops (was {}) after filtering by: {}", tiamatStops.size(), numberOfStopBeforeFiltering, importParams.targetTopographicPlaces);
        if (importParams.onlyMatchOutsideTopographicPlaces != null && !importParams.onlyMatchOutsideTopographicPlaces.isEmpty()) {
            numberOfStopBeforeFiltering = tiamatStops.size();
            logger.info("Filtering stops outside given list of topographic places: {}", importParams.onlyMatchOutsideTopographicPlaces);
            tiamatStops = zoneTopographicPlaceFilter.filterByTopographicPlaceMatch(importParams.onlyMatchOutsideTopographicPlaces, tiamatStops, true);
            logger.info("Got {} stops (was {}) after filtering", tiamatStops.size(), numberOfStopBeforeFiltering);
        }
        if (!isImportTypeIdMatch) {
            logger.info("Running stop place post filter steps");
            tiamatStops = stopPlacePostFilterSteps.run(tiamatStops);
        }
        if (importParams.forceStopType != null) {
            logger.info("Forcing stop type to " + importParams.forceStopType);
            tiamatStops.forEach(stopPlace -> stopPlace.setStopPlaceType(importParams.forceStopType));
        }
        Collection<org.rutebanken.netex.model.StopPlace> importedOrMatchedNetexStopPlaces;
        logger.info("The import type is: {}", importParams.importType);
        if (importParams.importType != null && importParams.importType.equals(ImportType.ID_MATCH)) {
            importedOrMatchedNetexStopPlaces = stopPlaceIdMatcher.matchStopPlaces(tiamatStops, stopPlacesCreatedMatchedOrUpdated);
        } else {
            final Lock lock = hazelcastInstance.getCPSubsystem().getLock(STOP_PLACE_IMPORT_LOCK_KEY);
            lock.lock();
            try {
                if (importParams.importType == null || importParams.importType.equals(ImportType.MERGE)) {
                    importedOrMatchedNetexStopPlaces = transactionalMergingStopPlacesImporter.importStopPlaces(tiamatStops, stopPlacesCreatedMatchedOrUpdated);
                } else if (importParams.importType.equals(ImportType.INITIAL)) {
                    importedOrMatchedNetexStopPlaces = parallelInitialStopPlaceImporter.importStopPlaces(tiamatStops, stopPlacesCreatedMatchedOrUpdated);
                } else if (importParams.importType.equals(ImportType.MATCH)) {
                    importedOrMatchedNetexStopPlaces = matchingAppendingIdStopPlacesImporter.importStopPlaces(tiamatStops, stopPlacesCreatedMatchedOrUpdated);
                } else {
                    throw new NotImplementedException("Import type " + importParams.importType + " not implemented ");
                }
            } finally {
                lock.unlock();
            }
        }
        // Filter uniques by StopPlace.id#version
        Map<String, org.rutebanken.netex.model.StopPlace> uniqueById = new HashMap<>();
        importedOrMatchedNetexStopPlaces.stream().forEach(e -> uniqueById.put(e.getId() + "#" + e.getVersion(), e));
        importedOrMatchedNetexStopPlaces = uniqueById.values();
        logger.info("Imported/matched/updated {} stop places", stopPlacesCreatedMatchedOrUpdated);
        tariffZonesFromStopsExporter.resolveTariffZones(importedOrMatchedNetexStopPlaces, responseSiteframe);
        if (responseSiteframe.getTariffZones() != null && responseSiteframe.getTariffZones().getTariffZone() != null && responseSiteframe.getTariffZones().getTariffZone().isEmpty()) {
            responseSiteframe.setTariffZones(null);
        }
        if (EXPORT_TOPOGRAPHIC_PLACES_FOR_STOPS) {
            List<TopographicPlace> netexTopographicPlaces = topographicPlacesExporter.export(findTopographicPlaceRefsFromStops(tiamatStops));
            if (!netexTopographicPlaces.isEmpty()) {
                responseSiteframe.withTopographicPlaces(new TopographicPlacesInFrame_RelStructure().withTopographicPlace(netexTopographicPlaces));
            }
        } else {
            clearTopographicPlaceRefs(importedOrMatchedNetexStopPlaces);
        }
        if (!importedOrMatchedNetexStopPlaces.isEmpty()) {
            logger.info("Add {} stops to response site frame", importedOrMatchedNetexStopPlaces.size());
            responseSiteframe.withStopPlaces(new StopPlacesInFrame_RelStructure().withStopPlace(importedOrMatchedNetexStopPlaces));
        } else {
            logger.info("No stops in response");
        }
    }
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) HashMap(java.util.HashMap) TopographicPlace(org.rutebanken.netex.model.TopographicPlace) NotImplementedException(org.apache.commons.lang3.NotImplementedException) StopPlacesInFrame_RelStructure(org.rutebanken.netex.model.StopPlacesInFrame_RelStructure) Lock(java.util.concurrent.locks.Lock) TopographicPlacesInFrame_RelStructure(org.rutebanken.netex.model.TopographicPlacesInFrame_RelStructure)

Example 18 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project pulsar-flink by streamnative.

the class PulsarTestBase method getProducer.

public static <T> Producer<T> getProducer(String topic, SchemaType type, Optional<Integer> partition, Class<T> tClass) throws PulsarClientException {
    String topicName;
    if (partition.isPresent()) {
        topicName = topic + PulsarOptions.PARTITION_SUFFIX + partition.get();
    } else {
        topicName = topic;
    }
    Producer producer;
    PulsarClient client = PulsarClient.builder().serviceUrl(getServiceUrl()).build();
    switch(type) {
        case BOOLEAN:
            producer = client.newProducer(Schema.BOOL).topic(topicName).create();
            break;
        case BYTES:
            producer = client.newProducer(Schema.BYTES).topic(topicName).create();
            break;
        case LOCAL_DATE:
            producer = client.newProducer(Schema.LOCAL_DATE).topic(topicName).create();
            break;
        case DATE:
            producer = client.newProducer(Schema.DATE).topic(topicName).create();
            break;
        case STRING:
            producer = client.newProducer(Schema.STRING).topic(topicName).create();
            break;
        case TIMESTAMP:
            producer = client.newProducer(Schema.TIMESTAMP).topic(topicName).create();
            break;
        case LOCAL_DATE_TIME:
            producer = client.newProducer(Schema.LOCAL_DATE_TIME).topic(topicName).create();
            break;
        case INT8:
            producer = client.newProducer(Schema.INT8).topic(topicName).create();
            break;
        case DOUBLE:
            producer = client.newProducer(Schema.DOUBLE).topic(topicName).create();
            break;
        case FLOAT:
            producer = client.newProducer(Schema.FLOAT).topic(topicName).create();
            break;
        case INT32:
            producer = client.newProducer(Schema.INT32).topic(topicName).create();
            break;
        case INT16:
            producer = client.newProducer(Schema.INT16).topic(topicName).create();
            break;
        case INT64:
            producer = client.newProducer(Schema.INT64).topic(topicName).create();
            break;
        case AVRO:
            SchemaDefinition<Object> schemaDefinition = SchemaDefinition.builder().withPojo(tClass).withJSR310ConversionEnabled(true).build();
            producer = client.newProducer(Schema.AVRO(schemaDefinition)).topic(topicName).create();
            break;
        case JSON:
            producer = client.newProducer(Schema.JSON(tClass)).topic(topicName).create();
            break;
        default:
            throw new NotImplementedException("Unsupported type " + type);
    }
    return producer;
}
Also used : Producer(org.apache.pulsar.client.api.Producer) NotImplementedException(org.apache.pulsar.shade.org.apache.commons.lang3.NotImplementedException) PulsarClient(org.apache.pulsar.client.api.PulsarClient)

Example 19 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project opencga by opencb.

the class ProtoFileWriter method open.

@Override
public boolean open() {
    if (outputStream == null) {
        try {
            OutputStream out = new BufferedOutputStream(new FileOutputStream(input.toFile()));
            if (StringUtils.equalsIgnoreCase(compression, "gzip") || StringUtils.equalsIgnoreCase(compression, "gz")) {
                out = new GzipCompressorOutputStream(out);
            } else if (StringUtils.isNotBlank(compression)) {
                throw new NotImplementedException("Proto compression not implemented yet: " + compression);
            }
            outputStream = out;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return true;
}
Also used : GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) FileOutputStream(java.io.FileOutputStream) NotImplementedException(org.apache.commons.lang3.NotImplementedException) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 20 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        x.addText("Extensions: Todo");
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType)
        x.addText(((DateTimeType) e).toHumanDisplay());
    else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.dstu2.model.DateType)
        x.addText(((org.hl7.fhir.dstu2.model.DateType) e).toHumanDisplay());
    else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType)
        x.addText(((BooleanType) e).getValue().toString());
    else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x);
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
    } else if (e instanceof org.hl7.fhir.dstu2.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu2.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
    } else if (e instanceof UriType) {
        renderUri((UriType) e, x);
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
    } else if (e instanceof Range) {
        renderRange((Range) e, x);
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.addText("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.addText(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        XhtmlNode c = x;
        ResourceWithReference tr = null;
        if (r.hasReferenceElement()) {
            tr = resolveReference(res, r.getReference());
            if (!r.getReference().startsWith("#")) {
                if (tr != null && tr.getReference() != null)
                    c = x.addTag("a").attribute("href", tr.getReference());
                else
                    c = x.addTag("a").attribute("href", r.getReference());
            }
        }
        // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
        if (r.hasDisplayElement()) {
            c.addText(r.getDisplay());
            if (tr != null) {
                c.addText(". Generated Summary: ");
                generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
            }
        } else if (tr != null) {
            generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
        } else {
            c.addText(r.getReference());
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof ElementDefinition) {
        x.addText("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
}
Also used : Meta(org.hl7.fhir.dstu2.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu2.model.Address) StringType(org.hl7.fhir.dstu2.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2.model.Attachment) UriType(org.hl7.fhir.dstu2.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu2.model.HumanName) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) Identifier(org.hl7.fhir.dstu2.model.Identifier) Coding(org.hl7.fhir.dstu2.model.Coding) Narrative(org.hl7.fhir.dstu2.model.Narrative) SampledData(org.hl7.fhir.dstu2.model.SampledData) Ratio(org.hl7.fhir.dstu2.model.Ratio) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) InstantType(org.hl7.fhir.dstu2.model.InstantType) Enumeration(org.hl7.fhir.dstu2.model.Enumeration) Reference(org.hl7.fhir.dstu2.model.Reference) BooleanType(org.hl7.fhir.dstu2.model.BooleanType) Resource(org.hl7.fhir.dstu2.model.Resource) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) Quantity(org.hl7.fhir.dstu2.model.Quantity) Period(org.hl7.fhir.dstu2.model.Period) Range(org.hl7.fhir.dstu2.model.Range) Base(org.hl7.fhir.dstu2.model.Base) Annotation(org.hl7.fhir.dstu2.model.Annotation) IdType(org.hl7.fhir.dstu2.model.IdType) Extension(org.hl7.fhir.dstu2.model.Extension) DateTimeType(org.hl7.fhir.dstu2.model.DateTimeType) CodeType(org.hl7.fhir.dstu2.model.CodeType) EventTiming(org.hl7.fhir.dstu2.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2.model.Timing) Base64BinaryType(org.hl7.fhir.dstu2.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)119 ArrayList (java.util.ArrayList)15 IOException (java.io.IOException)11 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10 List (java.util.List)8 HashMap (java.util.HashMap)7 Base64 (org.apache.commons.codec.binary.Base64)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)4 Logger (org.slf4j.Logger)4 Description (ca.uhn.fhir.model.api.annotation.Description)3 Operation (ca.uhn.fhir.rest.annotation.Operation)3 ControlFlowNode (fr.inria.controlflow.ControlFlowNode)3 Rhyme (io.wcm.caravan.rhyme.api.Rhyme)3 HalResponse (io.wcm.caravan.rhyme.api.common.HalResponse)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 Resource (org.hl7.fhir.r4b.model.Resource)3 Resource (org.hl7.fhir.r5.model.Resource)3 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)3