use of com.microsoft.tooling.msservices.model.storage.TableEntity in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method getTableEntity.
@NotNull
private static TableEntity getTableEntity(@NotNull String tableName, @NotNull DynamicTableEntity dte) {
String partitionKey = Strings.nullToEmpty(dte.getPartitionKey());
String rowKey = Strings.nullToEmpty(dte.getRowKey());
String eTag = Strings.nullToEmpty(dte.getEtag());
Calendar timestamp = new GregorianCalendar();
if (dte.getTimestamp() != null) {
timestamp.setTime(dte.getTimestamp());
}
Map<String, Property> properties = new HashMap<String, Property>();
if (dte.getProperties() != null) {
for (Entry<String, EntityProperty> entry : dte.getProperties().entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
String key = entry.getKey();
Property property;
switch(entry.getValue().getEdmType()) {
case BOOLEAN:
property = new Property(entry.getValue().getValueAsBooleanObject());
break;
case DATE_TIME:
Calendar value = new GregorianCalendar();
value.setTime(entry.getValue().getValueAsDate());
property = new Property(value);
break;
case DOUBLE:
property = new Property(entry.getValue().getValueAsDoubleObject());
break;
case GUID:
property = new Property(entry.getValue().getValueAsUUID());
break;
case INT32:
property = new Property(entry.getValue().getValueAsIntegerObject());
break;
case INT64:
property = new Property(entry.getValue().getValueAsLongObject());
break;
case STRING:
property = new Property(entry.getValue().getValueAsString());
break;
default:
property = new Property(entry.getValue().getValueAsString());
break;
}
properties.put(key, property);
}
}
}
return new TableEntity(partitionKey, rowKey, tableName, eTag, timestamp, properties);
}
use of com.microsoft.tooling.msservices.model.storage.TableEntity in project azure-tools-for-java by Microsoft.
the class TableFileEditor method editEntity.
private void editEntity() {
TableEntity[] selectedEntities = getSelectedEntities();
if (selectedEntities != null && selectedEntities.length > 0) {
final TableEntity selectedEntity = selectedEntities[0];
final TableEntityForm form = new TableEntityForm(project);
form.setTableName(table.getName());
form.setStorageAccount(storageAccount);
form.setTableEntity(selectedEntity);
form.setTitle("Edit Entity");
form.setOnFinish(new Runnable() {
@Override
public void run() {
tableEntities.set(entitiesTable.getSelectedRow(), form.getTableEntity());
refreshGrid();
}
});
form.show();
}
}
use of com.microsoft.tooling.msservices.model.storage.TableEntity in project azure-tools-for-java by Microsoft.
the class TableFileEditor method getSelectedEntities.
private TableEntity[] getSelectedEntities() {
if (tableEntities == null) {
return null;
}
int partitionIdIndex = -1;
int rowIdIndex = -1;
for (int i = 0; i < entitiesTable.getColumnCount(); i++) {
String columnName = entitiesTable.getColumnName(i);
if (columnName.equals(PARTITION_KEY)) {
partitionIdIndex = i;
}
if (columnName.equals(ROW_KEY)) {
rowIdIndex = i;
}
}
ArrayList<TableEntity> selectedEntities = new ArrayList<TableEntity>();
for (int i : entitiesTable.getSelectedRows()) {
for (TableEntity tableEntity : tableEntities) {
String partitionValue = entitiesTable.getValueAt(i, partitionIdIndex).toString();
String rowIdValue = entitiesTable.getValueAt(i, rowIdIndex).toString();
if (tableEntity.getPartitionKey().equals(partitionValue) && tableEntity.getRowKey().equals(rowIdValue)) {
selectedEntities.add(tableEntity);
}
}
}
return selectedEntities.toArray(new TableEntity[selectedEntities.size()]);
}
Aggregations