Search in sources :

Example 1 with ByteArrayType

use of org.bimserver.models.store.ByteArrayType in project BIMserver by opensourceBIM.

the class BimServer method cloneAndAdd.

public Type cloneAndAdd(DatabaseSession session, Type input) throws BimserverDatabaseException {
    if (input instanceof BooleanType) {
        BooleanType booleanType = session.create(BooleanType.class);
        booleanType.setValue(((BooleanType) input).isValue());
        session.store(booleanType);
        return booleanType;
    } else if (input instanceof StringType) {
        StringType stringType = session.create(StringType.class);
        stringType.setValue(((StringType) input).getValue());
        session.store(stringType);
        return stringType;
    } else if (input instanceof DoubleType) {
        DoubleType doubleType = session.create(DoubleType.class);
        doubleType.setValue(((DoubleType) input).getValue());
        session.store(doubleType);
        return doubleType;
    } else if (input instanceof LongType) {
        LongType longType = session.create(LongType.class);
        longType.setValue(((LongType) input).getValue());
        session.store(longType);
        return longType;
    } else if (input instanceof ByteArrayType) {
        ByteArrayType byteArrayType = session.create(ByteArrayType.class);
        byteArrayType.setValue(((ByteArrayType) input).getValue());
        session.store(byteArrayType);
        return byteArrayType;
    }
    return null;
}
Also used : LongType(org.bimserver.models.store.LongType) StringType(org.bimserver.models.store.StringType) DoubleType(org.bimserver.models.store.DoubleType) ByteArrayType(org.bimserver.models.store.ByteArrayType) BooleanType(org.bimserver.models.store.BooleanType)

Example 2 with ByteArrayType

use of org.bimserver.models.store.ByteArrayType in project BIMserver by opensourceBIM.

the class PluginConfiguration method fromDefaults.

public static PluginConfiguration fromDefaults(ObjectDefinition settingsDefinition) {
    if (settingsDefinition == null) {
        return null;
    }
    PluginConfiguration pluginConfiguration = new PluginConfiguration();
    for (ParameterDefinition parameterDefinition : settingsDefinition.getParameters()) {
        if (parameterDefinition.getDefaultValue() != null) {
            Type value = parameterDefinition.getDefaultValue();
            Object newValue = null;
            if (value instanceof PrimitiveType) {
                if (value instanceof BooleanType) {
                    newValue = ((BooleanType) value).isValue();
                } else if (value instanceof StringType) {
                    newValue = ((StringType) value).getValue();
                } else if (value instanceof DoubleType) {
                    newValue = ((DoubleType) value).getValue();
                } else if (value instanceof LongType) {
                    newValue = ((LongType) value).getValue();
                } else if (value instanceof ByteArrayType) {
                    newValue = ((ByteArrayType) value).getValue();
                }
            } else if (value instanceof ArrayType) {
                throw new NotImplementedException("ArrayType not implemented");
            } else if (value instanceof ObjectType) {
                throw new NotImplementedException("ObjectType not implemented");
            }
            pluginConfiguration.values.put(parameterDefinition.getIdentifier(), newValue);
        }
    }
    return pluginConfiguration;
}
Also used : SLongType(org.bimserver.interfaces.objects.SLongType) LongType(org.bimserver.models.store.LongType) SStringType(org.bimserver.interfaces.objects.SStringType) StringType(org.bimserver.models.store.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) SBooleanType(org.bimserver.interfaces.objects.SBooleanType) BooleanType(org.bimserver.models.store.BooleanType) ByteArrayType(org.bimserver.models.store.ByteArrayType) SArrayType(org.bimserver.interfaces.objects.SArrayType) SByteArrayType(org.bimserver.interfaces.objects.SByteArrayType) ArrayType(org.bimserver.models.store.ArrayType) ObjectType(org.bimserver.models.store.ObjectType) SObjectType(org.bimserver.interfaces.objects.SObjectType) SBooleanType(org.bimserver.interfaces.objects.SBooleanType) SStringType(org.bimserver.interfaces.objects.SStringType) SLongType(org.bimserver.interfaces.objects.SLongType) BooleanType(org.bimserver.models.store.BooleanType) PrimitiveType(org.bimserver.models.store.PrimitiveType) SDoubleType(org.bimserver.interfaces.objects.SDoubleType) SType(org.bimserver.interfaces.objects.SType) ByteArrayType(org.bimserver.models.store.ByteArrayType) DoubleType(org.bimserver.models.store.DoubleType) LongType(org.bimserver.models.store.LongType) ObjectType(org.bimserver.models.store.ObjectType) Type(org.bimserver.models.store.Type) SArrayType(org.bimserver.interfaces.objects.SArrayType) SByteArrayType(org.bimserver.interfaces.objects.SByteArrayType) StringType(org.bimserver.models.store.StringType) SObjectType(org.bimserver.interfaces.objects.SObjectType) ArrayType(org.bimserver.models.store.ArrayType) SDoubleType(org.bimserver.interfaces.objects.SDoubleType) DoubleType(org.bimserver.models.store.DoubleType) ByteArrayType(org.bimserver.models.store.ByteArrayType) SByteArrayType(org.bimserver.interfaces.objects.SByteArrayType) PrimitiveType(org.bimserver.models.store.PrimitiveType) ParameterDefinition(org.bimserver.models.store.ParameterDefinition)

Aggregations

BooleanType (org.bimserver.models.store.BooleanType)2 ByteArrayType (org.bimserver.models.store.ByteArrayType)2 DoubleType (org.bimserver.models.store.DoubleType)2 LongType (org.bimserver.models.store.LongType)2 StringType (org.bimserver.models.store.StringType)2 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1 SArrayType (org.bimserver.interfaces.objects.SArrayType)1 SBooleanType (org.bimserver.interfaces.objects.SBooleanType)1 SByteArrayType (org.bimserver.interfaces.objects.SByteArrayType)1 SDoubleType (org.bimserver.interfaces.objects.SDoubleType)1 SLongType (org.bimserver.interfaces.objects.SLongType)1 SObjectType (org.bimserver.interfaces.objects.SObjectType)1 SStringType (org.bimserver.interfaces.objects.SStringType)1 SType (org.bimserver.interfaces.objects.SType)1 ArrayType (org.bimserver.models.store.ArrayType)1 ObjectType (org.bimserver.models.store.ObjectType)1 ParameterDefinition (org.bimserver.models.store.ParameterDefinition)1 PrimitiveType (org.bimserver.models.store.PrimitiveType)1 Type (org.bimserver.models.store.Type)1