Search in sources :

Example 31 with NotImplementedException

use of org.apache.commons.lang.NotImplementedException in project OpenRefine by OpenRefine.

the class EditBatchProcessor method performEdit.

/**
 * Performs the next edit in the batch.
 *
 * @throws InterruptedException
 */
public void performEdit() throws InterruptedException {
    if (remainingEdits() == 0) {
        return;
    }
    if (batchCursor == currentBatch.size()) {
        prepareNewBatch();
    }
    TermedStatementEntityEdit update = currentBatch.get(batchCursor);
    // Rewrite mentions to new entities
    ReconEntityRewriter rewriter = new ReconEntityRewriter(library, update.getEntityId());
    try {
        update = rewriter.rewrite(update);
    } catch (NewEntityNotCreatedYetException e) {
        logger.warn("Failed to rewrite update on entity " + update.getEntityId() + ". Missing entity: " + e.getMissingEntity() + ". Skipping update.");
        batchCursor++;
        return;
    }
    try {
        // New entities
        if (update.isNew()) {
            ReconEntityIdValue newCell = (ReconEntityIdValue) update.getEntityId();
            // TODO Antonin, 2022-02-11: remove this casting once we have https://github.com/Wikidata/Wikidata-Toolkit/issues/651
            if (newCell instanceof ItemIdValue) {
                update = update.normalizeLabelsAndAliases();
                ItemDocument itemDocument = (ItemDocument) update.toNewEntity();
                ItemDocument createdDoc = editor.createItemDocument(itemDocument, summary, tags);
                library.setId(newCell.getReconInternalId(), createdDoc.getEntityId().getId());
            } else if (newCell instanceof MediaInfoIdValue) {
                update = update.normalizeLabelsAndAliases();
                throw new NotImplementedException();
            }
        } else {
            // Existing entities
            EntityUpdate entityUpdate = update.toEntityUpdate(currentDocs.get(update.getEntityId().getId()));
            editor.editEntityDocument(entityUpdate, false, summary, tags);
        }
    } catch (MediaWikiApiErrorException e) {
        // TODO find a way to report these errors to the user in a nice way
        logger.warn("MediaWiki error while editing [" + e.getErrorCode() + "]: " + e.getErrorMessage());
    } catch (IOException e) {
        logger.warn("IO error while editing: " + e.getMessage());
    }
    batchCursor++;
}
Also used : ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) EntityUpdate(org.wikidata.wdtk.datamodel.interfaces.EntityUpdate) ItemDocument(org.wikidata.wdtk.datamodel.interfaces.ItemDocument) NewEntityNotCreatedYetException(org.openrefine.wikidata.schema.exceptions.NewEntityNotCreatedYetException) MediaInfoIdValue(org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue) ReconEntityIdValue(org.openrefine.wikidata.schema.entityvalues.ReconEntityIdValue) NotImplementedException(org.apache.commons.lang.NotImplementedException) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) IOException(java.io.IOException) MediaWikiApiErrorException(org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException)

Example 32 with NotImplementedException

use of org.apache.commons.lang.NotImplementedException in project janusgraph by JanusGraph.

the class JanusGraphTest method testBatchPropertiesPrefetchingFromEdges.

@ParameterizedTest
@ValueSource(ints = { 0, 1, 2, 3, 10, 15, Integer.MAX_VALUE })
public void testBatchPropertiesPrefetchingFromEdges(int txCacheSize) {
    boolean inmemoryBackend = getConfig().get(STORAGE_BACKEND).equals("inmemory");
    int numV = 10;
    int expectedVerticesPrefetch = Math.min(txCacheSize, 4);
    JanusGraphVertex mainVertex = graph.addVertex("id", 0);
    for (int i = 1; i <= numV; i++) {
        JanusGraphVertex adjacentVertex = graph.addVertex("id", i);
        mainVertex.addEdge("knows", adjacentVertex, "id", i);
    }
    graph.tx().commit();
    if (!inmemoryBackend) {
        clopen(option(BATCH_PROPERTY_PREFETCHING), true, option(TX_CACHE_SIZE), txCacheSize);
    }
    GraphTraversalSource gts = graph.traversal();
    for (Direction direction : Direction.values()) {
        GraphTraversal<Vertex, Edge> graphEdgeTraversal = gts.V().has("id", 0).outE("knows").has("id", P.within(4, 5, 6, 7));
        GraphTraversal<Vertex, Vertex> graphVertexTraversal;
        switch(direction) {
            case IN:
                graphVertexTraversal = graphEdgeTraversal.inV();
                break;
            case OUT:
                graphVertexTraversal = graphEdgeTraversal.outV();
                break;
            case BOTH:
                graphVertexTraversal = graphEdgeTraversal.bothV();
                break;
            default:
                throw new NotImplementedException("No implementation found for direction: " + direction.name());
        }
        TraversalMetrics traversalMetrics = graphVertexTraversal.has("id", P.within(4, 5, 6, 7)).values("id").profile().next();
        Metrics janusGraphEdgeVertexStepMetrics = getStepMetrics(traversalMetrics, JanusGraphEdgeVertexStep.class);
        if (inmemoryBackend) {
            assertNull(janusGraphEdgeVertexStepMetrics);
        } else {
            assertNotNull(janusGraphEdgeVertexStepMetrics);
            assertTrue(janusGraphEdgeVertexStepMetrics.getName().endsWith("(" + direction.name() + ")"));
            if (expectedVerticesPrefetch > 1 && !OUT.equals(direction)) {
                assertContains(janusGraphEdgeVertexStepMetrics, "multiPreFetch", "true");
                // 4 is the number of retrieved IN vertices
                boolean withAdditionalOutVertex = BOTH.equals(direction) && txCacheSize > 4;
                assertContains(janusGraphEdgeVertexStepMetrics, "vertices", expectedVerticesPrefetch + (withAdditionalOutVertex ? 1 : 0));
            } else {
                assertNotContains(janusGraphEdgeVertexStepMetrics, "multiPreFetch", "true");
            }
        }
    }
}
Also used : GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) CacheVertex(org.janusgraph.graphdb.vertices.CacheVertex) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphAssert.getStepMetrics(org.janusgraph.testutil.JanusGraphAssert.getStepMetrics) Metrics(org.apache.tinkerpop.gremlin.process.traversal.util.Metrics) ScanMetrics(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics) TraversalMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) NotImplementedException(org.apache.commons.lang.NotImplementedException) Direction(org.apache.tinkerpop.gremlin.structure.Direction) AbstractEdge(org.janusgraph.graphdb.relations.AbstractEdge) JanusGraphEdge(org.janusgraph.core.JanusGraphEdge) Edge(org.apache.tinkerpop.gremlin.structure.Edge) TraversalMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with NotImplementedException

use of org.apache.commons.lang.NotImplementedException in project BroadleafCommerce by BroadleafCommerce.

the class BandedShippingModule method calculateShipping.

private void calculateShipping(FulfillmentGroup fulfillmentGroup) {
    if (!isValidModuleForService(fulfillmentGroup.getService()) && !isDefaultModule()) {
        LOG.info("fulfillment group (" + fulfillmentGroup.getId() + ") with a service type of (" + fulfillmentGroup.getService() + ") is not valid for this module service type (" + getServiceName() + ")");
        return;
    }
    if (fulfillmentGroup.getFulfillmentGroupItems().size() == 0) {
        LOG.warn("fulfillment group (" + fulfillmentGroup.getId() + ") does not contain any fulfillment group items. Unable to price banded shipping");
        fulfillmentGroup.setShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
        fulfillmentGroup.setSaleShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
        fulfillmentGroup.setRetailShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
        return;
    }
    Address address = fulfillmentGroup.getAddress();
    String state = null;
    if (StringUtils.isNotBlank(address.getStateProvinceRegion())) {
        state = address.getStateProvinceRegion();
    } else if (address.getState() != null) {
        state = address.getState().getAbbreviation();
    }
    BigDecimal retailTotal = new BigDecimal(0);
    String feeType = feeTypeMapping.get(fulfillmentGroup.getMethod());
    String feeSubType = ((feeSubTypeMapping.get(state) == null) ? feeSubTypeMapping.get("ALL") : feeSubTypeMapping.get(state));
    for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
        BigDecimal price = (fulfillmentGroupItem.getRetailPrice() != null) ? fulfillmentGroupItem.getRetailPrice().getAmount().multiply(BigDecimal.valueOf(fulfillmentGroupItem.getQuantity())) : null;
        if (price == null) {
            price = fulfillmentGroupItem.getOrderItem().getRetailPrice().getAmount().multiply(BigDecimal.valueOf(fulfillmentGroupItem.getQuantity()));
        }
        retailTotal = retailTotal.add(price);
    }
    ShippingRate sr = shippingRateService.readShippingRateByFeeTypesUnityQty(feeType, feeSubType, retailTotal);
    if (sr == null) {
        throw new NotImplementedException("Shipping rate " + fulfillmentGroup.getMethod() + " not supported");
    }
    BigDecimal shippingPrice = new BigDecimal(0);
    if (sr.getBandResultPercent().compareTo(0) > 0) {
        BigDecimal percent = new BigDecimal(sr.getBandResultPercent() / 100);
        shippingPrice = retailTotal.multiply(percent);
    } else {
        shippingPrice = sr.getBandResultQuantity();
    }
    fulfillmentGroup.setShippingPrice(BroadleafCurrencyUtils.getMoney(shippingPrice, fulfillmentGroup.getOrder().getCurrency()));
    fulfillmentGroup.setSaleShippingPrice(fulfillmentGroup.getShippingPrice());
    fulfillmentGroup.setRetailShippingPrice(fulfillmentGroup.getSaleShippingPrice());
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) ShippingRate(org.broadleafcommerce.core.pricing.domain.ShippingRate) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) NotImplementedException(org.apache.commons.lang.NotImplementedException) BigDecimal(java.math.BigDecimal)

Example 34 with NotImplementedException

use of org.apache.commons.lang.NotImplementedException in project symmetric-ds by JumpMind.

the class AbstractTriggerTemplate method fillOutColumnTemplate.

protected ColumnString fillOutColumnTemplate(String origTableAlias, String tableAlias, String columnPrefix, Column column, DataEventType dml, boolean isOld, Channel channel, Trigger trigger) {
    boolean isLob = symmetricDialect.getPlatform().isLob(column.getMappedTypeCode());
    String templateToUse = null;
    if (column.getJdbcTypeName() != null && (column.getJdbcTypeName().toUpperCase().contains(TypeMap.GEOMETRY)) && StringUtils.isNotBlank(geometryColumnTemplate)) {
        templateToUse = geometryColumnTemplate;
    } else if (column.getJdbcTypeName() != null && (column.getJdbcTypeName().toUpperCase().contains(TypeMap.GEOGRAPHY)) && StringUtils.isNotBlank(geographyColumnTemplate)) {
        templateToUse = geographyColumnTemplate;
    } else {
        switch(column.getMappedTypeCode()) {
            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.INTEGER:
            case Types.BIGINT:
            case Types.FLOAT:
            case Types.REAL:
            case Types.DOUBLE:
            case Types.NUMERIC:
            case Types.DECIMAL:
                templateToUse = numberColumnTemplate;
                break;
            case Types.CHAR:
            case Types.NCHAR:
            case Types.VARCHAR:
            case ColumnTypes.NVARCHAR:
                templateToUse = stringColumnTemplate;
                break;
            case ColumnTypes.SQLXML:
                templateToUse = xmlColumnTemplate;
                break;
            case Types.ARRAY:
                templateToUse = arrayColumnTemplate;
                break;
            case Types.LONGVARCHAR:
            case ColumnTypes.LONGNVARCHAR:
                if (!isLob) {
                    templateToUse = stringColumnTemplate;
                    break;
                }
            case Types.CLOB:
                if (isOld && symmetricDialect.needsToSelectLobData()) {
                    templateToUse = emptyColumnTemplate;
                } else {
                    templateToUse = clobColumnTemplate;
                }
                break;
            case Types.BINARY:
            case Types.VARBINARY:
                if (isNotBlank(binaryColumnTemplate)) {
                    templateToUse = binaryColumnTemplate;
                    break;
                }
            case Types.BLOB:
                if (requiresWrappedBlobTemplateForBlobType()) {
                    templateToUse = wrappedBlobColumnTemplate;
                    break;
                }
            case Types.LONGVARBINARY:
            case // SQL-Server ntext binary type
            -10:
                if (column.getJdbcTypeName() != null && (column.getJdbcTypeName().toUpperCase().contains(TypeMap.IMAGE)) && StringUtils.isNotBlank(imageColumnTemplate)) {
                    if (isOld) {
                        templateToUse = emptyColumnTemplate;
                    } else {
                        templateToUse = imageColumnTemplate;
                    }
                } else if (isOld && symmetricDialect.needsToSelectLobData()) {
                    templateToUse = emptyColumnTemplate;
                } else {
                    templateToUse = blobColumnTemplate;
                }
                break;
            case Types.DATE:
                if (noDateColumnTemplate()) {
                    templateToUse = datetimeColumnTemplate;
                    break;
                }
                templateToUse = dateColumnTemplate;
                break;
            case Types.TIME:
                if (noTimeColumnTemplate()) {
                    templateToUse = datetimeColumnTemplate;
                    break;
                }
                templateToUse = timeColumnTemplate;
                break;
            case Types.TIMESTAMP:
                templateToUse = datetimeColumnTemplate;
                break;
            case Types.BOOLEAN:
            case Types.BIT:
                templateToUse = booleanColumnTemplate;
                break;
            default:
                if (column.getJdbcTypeName() != null) {
                    if (column.getJdbcTypeName().toUpperCase().equals(TypeMap.INTERVAL)) {
                        templateToUse = numberColumnTemplate;
                        break;
                    } else if (column.getMappedType().equals(TypeMap.TIMESTAMPTZ) && StringUtils.isNotBlank(this.dateTimeWithTimeZoneColumnTemplate)) {
                        templateToUse = this.dateTimeWithTimeZoneColumnTemplate;
                        break;
                    } else if (column.getMappedType().equals(TypeMap.TIMESTAMPLTZ) && StringUtils.isNotBlank(this.dateTimeWithLocalTimeZoneColumnTemplate)) {
                        templateToUse = this.dateTimeWithLocalTimeZoneColumnTemplate;
                        break;
                    }
                }
                if (StringUtils.isBlank(templateToUse) && StringUtils.isNotBlank(this.otherColumnTemplate)) {
                    templateToUse = this.otherColumnTemplate;
                    break;
                }
                throw new NotImplementedException(column.getName() + " is of type " + column.getMappedType() + " with JDBC type of " + column.getJdbcTypeName());
        }
    }
    if (dml == DataEventType.DELETE && isLob && requiresEmptyLobTemplateForDeletes()) {
        templateToUse = emptyColumnTemplate;
    } else if (isLob && trigger.isUseStreamLobs()) {
        templateToUse = emptyColumnTemplate;
    }
    if (templateToUse != null) {
        templateToUse = templateToUse.trim();
    } else {
        throw new NotImplementedException();
    }
    String formattedColumnText = FormatUtils.replace("columnName", String.format("%s%s", columnPrefix, column.getName()), templateToUse);
    formattedColumnText = FormatUtils.replace("columnSize", column.getSize(), formattedColumnText);
    formattedColumnText = FormatUtils.replace("masterCollation", symmetricDialect.getMasterCollation(), formattedColumnText);
    if (isLob) {
        formattedColumnText = symmetricDialect.massageForLob(formattedColumnText, channel);
    }
    formattedColumnText = FormatUtils.replace("origTableAlias", origTableAlias, formattedColumnText);
    formattedColumnText = FormatUtils.replace("tableAlias", tableAlias, formattedColumnText);
    formattedColumnText = FormatUtils.replace("prefixName", symmetricDialect.getTablePrefix(), formattedColumnText);
    return new ColumnString(formattedColumnText, isLob);
}
Also used : NotImplementedException(org.apache.commons.lang.NotImplementedException)

Example 35 with NotImplementedException

use of org.apache.commons.lang.NotImplementedException in project symmetric-ds by JumpMind.

the class AbstractTriggerTemplate method createTriggerDDL.

public String createTriggerDDL(DataEventType dml, Trigger trigger, TriggerHistory history, Channel channel, String tablePrefix, Table originalTable, String defaultCatalog, String defaultSchema) {
    Table table = originalTable.copyAndFilterColumns(history.getParsedColumnNames(), history.getParsedPkColumnNames(), true);
    String ddl = sqlTemplates.get(dml.name().toLowerCase() + "TriggerTemplate");
    if (dml.getDmlType().equals(DmlType.UPDATE) && trigger.isUseHandleKeyUpdates()) {
        String temp = sqlTemplates.get(dml.name().toLowerCase() + "HandleKeyUpdates" + "TriggerTemplate");
        if (StringUtils.trimToNull(temp) != null) {
            ddl = temp;
        }
    }
    if (ddl == null) {
        throw new NotImplementedException(dml.name() + " trigger is not implemented for " + symmetricDialect.getPlatform().getName());
    }
    return replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, originalTable, table, defaultCatalog, defaultSchema, ddl);
}
Also used : Table(org.jumpmind.db.model.Table) NotImplementedException(org.apache.commons.lang.NotImplementedException)

Aggregations

NotImplementedException (org.apache.commons.lang.NotImplementedException)36 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Path (org.apache.hadoop.fs.Path)4 ASTNode (com.intellij.lang.ASTNode)3 IElementType (com.intellij.psi.tree.IElementType)3 File (java.io.File)3 Collection (java.util.Collection)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Entry (java.util.Map.Entry)3 NotNull (org.jetbrains.annotations.NotNull)3 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 TableName (org.apache.hadoop.hbase.TableName)2 DMLProgram (org.apache.sysml.parser.DMLProgram)2 XSDConstrainingFacet (org.eclipse.xsd.XSDConstrainingFacet)2