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++;
}
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");
}
}
}
}
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());
}
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);
}
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);
}
Aggregations