in fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java [588:684]
public String getDefaultEntryKey(final String entitySetName, final Entity entity) throws IOException {
try {
String res;
if ("OrderDetails".equals(entitySetName)) {
int productID;
if (entity.getProperty("OrderID") == null || entity.getProperty("ProductID") == null) {
if (Commons.SEQUENCE.containsKey(entitySetName)) {
productID = Commons.SEQUENCE.get(entitySetName) + 1;
res = "OrderID=1" + ",ProductID=" + String.valueOf(productID);
} else {
throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
}
} else {
productID = (Integer) entity.getProperty("OrderID").asPrimitive();
res = "OrderID=" + entity.getProperty("OrderID").asPrimitive()
+ ",ProductID=" + entity.getProperty("ProductID").asPrimitive();
}
Commons.SEQUENCE.put(entitySetName, productID);
} else if ("Message".equals(entitySetName)) {
int messageId;
if (entity.getProperty("MessageId") == null || entity.getProperty("FromUsername") == null) {
if (Commons.SEQUENCE.containsKey(entitySetName)) {
messageId = Commons.SEQUENCE.get(entitySetName) + 1;
res = "FromUsername=1" + ",MessageId=" + String.valueOf(messageId);
} else {
throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
}
} else {
messageId = (Integer) entity.getProperty("MessageId").asPrimitive();
res = "FromUsername=" + entity.getProperty("FromUsername").asPrimitive()
+ ",MessageId=" + entity.getProperty("MessageId").asPrimitive();
}
Commons.SEQUENCE.put(entitySetName, messageId);
} else if ("PersonDetails".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "PersonID");
} else if ("Order".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "OrderId");
} else if ("Product".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "ProductId");
} else if ("Orders".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "OrderID");
} else if ("Customer".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "CustomerId");
} else if ("Customers".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "PersonID");
} else if ("Person".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "PersonId");
} else if ("ComputerDetail".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "ComputerDetailId");
} else if ("AllGeoTypesSet".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "Id");
} else if ("CustomerInfo".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "CustomerInfoId");
} else if ("Car".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "VIN");
} else if ("RowIndex".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "Id");
} else if ("Login".equals(entitySetName)) {
res = (String) entity.getProperty("Username").asPrimitive();
} else if ("Products".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "ProductID");
} else if ("ProductDetails".equals(entitySetName)) {
int productId;
int productDetailId;
if (entity.getProperty("ProductID") == null || entity.getProperty("ProductDetailID") == null) {
if (Commons.SEQUENCE.containsKey(entitySetName) && Commons.SEQUENCE.containsKey("Products")) {
productId = Commons.SEQUENCE.get("Products") + 1;
productDetailId = Commons.SEQUENCE.get(entitySetName) + 1;
res = "ProductID=" + String.valueOf(productId) + ",ProductDetailID=" + String.valueOf(productDetailId);
} else {
throw new IOException(String.format("Unable to retrieve entity key value for %s", entitySetName));
}
Commons.SEQUENCE.put(entitySetName, productDetailId);
} else {
productId = (Integer) entity.getProperty("ProductID").asPrimitive();
productDetailId = (Integer) entity.getProperty("ProductDetailID").asPrimitive();
res = "ProductID=" + entity.getProperty("ProductID").asPrimitive()
+ ",ProductDetailID=" + entity.getProperty("ProductDetailID").asPrimitive();
}
Commons.SEQUENCE.put(entitySetName, productDetailId);
Commons.SEQUENCE.put("Products", productId);
} else if ("PaymentInstrument".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "PaymentInstrumentID");
} else if ("Advertisements".equals(entitySetName)) {
res = UUID.randomUUID().toString();
} else if ("People".equals(entitySetName)) {
res = getDefaultEntryKey(entitySetName, entity, "PersonID");
} else {
throw new IOException(String.format("EntitySet '%s' not found", entitySetName));
}
return res;
} catch (Exception e) {
throw new NotFoundException(e);
}
}