Search in sources :

Example 1 with Property

use of com.microsoft.tooling.msservices.model.storage.TableEntity.Property in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getEntityProperties.

@NotNull
private static HashMap<String, EntityProperty> getEntityProperties(@NotNull Map<String, Property> properties) throws AzureCmdException {
    HashMap<String, EntityProperty> entityProperties = new HashMap<String, EntityProperty>();
    for (Entry<String, Property> entry : properties.entrySet()) {
        String key = entry.getKey();
        Property property = entry.getValue();
        EntityProperty entityProperty;
        switch(property.getType()) {
            case Boolean:
                entityProperty = new EntityProperty(property.getValueAsBoolean());
                break;
            case DateTime:
                entityProperty = new EntityProperty(property.getValueAsCalendar().getTime());
                break;
            case Double:
                entityProperty = new EntityProperty(property.getValueAsDouble());
                break;
            case Uuid:
                entityProperty = new EntityProperty(property.getValueAsUuid());
                break;
            case Integer:
                entityProperty = new EntityProperty(property.getValueAsInteger());
                break;
            case Long:
                entityProperty = new EntityProperty(property.getValueAsLong());
                break;
            case String:
                entityProperty = new EntityProperty(property.getValueAsString());
                break;
            default:
                entityProperty = new EntityProperty(property.getValueAsString());
                break;
        }
        entityProperties.put(key, entityProperty);
    }
    return entityProperties;
}
Also used : Property(com.microsoft.tooling.msservices.model.storage.TableEntity.Property) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 2 with Property

use of com.microsoft.tooling.msservices.model.storage.TableEntity.Property 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);
}
Also used : TableEntity(com.microsoft.tooling.msservices.model.storage.TableEntity) Property(com.microsoft.tooling.msservices.model.storage.TableEntity.Property) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Aggregations

NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)2 Property (com.microsoft.tooling.msservices.model.storage.TableEntity.Property)2 TableEntity (com.microsoft.tooling.msservices.model.storage.TableEntity)1