/** * Gets the instance of. * * @param type * the type * @return the instance of */ private static ColumnFamilyType getInstanceOf(String type) { if (type.equals(Type.COLUMN_FAMILY.name())) { return ColumnFamilyType.Standard; } else { return ColumnFamilyType.Super; } } }
/** * Checks if is cql3 enabled. * * @param tableInfo * the table info * @return true, if is cql3 enabled */ private boolean isCql3Enabled(TableInfo tableInfo) { Properties cfProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = cfProperties != null ? cfProperties .getProperty(CassandraConstants.DEFAULT_VALIDATION_CLASS) : null; // For normal columns boolean isCounterColumnType = isCounterColumnType(tableInfo, defaultValidationClass); return containsCompositeKey(tableInfo) || containsCollectionColumns(tableInfo) || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && (containsEmbeddedColumns(tableInfo) || containsElementCollectionColumns(tableInfo))) && !isCounterColumnType || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && !tableInfo .getType().equals(Type.SUPER_COLUMN_FAMILY.name())); }
for (TableInfo tableInfo : tableInfos) if (isCql3Enabled(tableInfo) && !tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name()))
/** * @param tableInfo * @return CfDef object */ private CfDef getTableMetadata(TableInfo tableInfo) { CfDef cfDef = new CfDef(); cfDef.setKeyspace(databaseName); cfDef.setName(tableInfo.getTableName()); cfDef.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(tableInfo.getTableIdType(), isCql3Enabled(tableInfo))); Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName); tables = schema != null ? schema.getTables() : null; Properties cFProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = null; if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { getSuperColumnFamilyMetadata(tableInfo, cfDef, defaultValidationClass); } else if (tableInfo.getType() != null) { getColumnFamilyMetadata(tableInfo, cfDef, cFProperties); } setColumnFamilyProperties(cfDef, cFProperties, null); return cfDef; }
/** * Gets the instance of. * * @param type * the type * @return the instance of */ private static ColumnFamilyType getInstanceOf(String type) { if (type.equals(Type.COLUMN_FAMILY.name())) { return ColumnFamilyType.Standard; } else { return ColumnFamilyType.Super; } } }
/** * * @param tableInfo */ private void validateCompoundKey(TableInfo tableInfo) { if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { throw new SchemaGenerationException( "Composite/Compound columns are not yet supported over Super column family by Cassandra", "cassandra", databaseName); } }
/** * * @param tableInfo * @return */ private boolean isCql3Enabled(TableInfo tableInfo) { return containsCompositeKey(tableInfo) || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && !tableInfo .getType().equals(Type.SUPER_COLUMN_FAMILY.name())); }
String idName = ((AbstractAttribute) targetEntityMetadata.getIdAttribute()).getJPAColumnName(); TableInfo targetTableInfo = new TableInfo(targetEntityMetadata.getTableName(), targetEntityType.name(), idClass, idName); if (joinTableName != null) TableInfo joinTableInfo = new TableInfo(joinTableName, Type.COLUMN_FAMILY.name(), String.class, "key"); if (!tableInfos.isEmpty() && !tableInfos.contains(joinTableInfo) || tableInfos.isEmpty())
? ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName() : null; TableInfo tableInfo = new TableInfo(entityMetadata.getTableName(), type.name(), idClassName, idName);
/** * @param tableInfo * @return CfDef object */ private CfDef getTableMetadata(TableInfo tableInfo) { CfDef cfDef = new CfDef(); cfDef.setKeyspace(databaseName); cfDef.setName(tableInfo.getTableName()); cfDef.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(tableInfo.getTableIdType(), isCql3Enabled(tableInfo))); Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName); tables = schema != null ? schema.getTables() : null; Properties cfProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = null; if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { getSuperColumnFamilyMetadata(tableInfo, cfDef, defaultValidationClass); } else if (tableInfo.getType() != null) { getColumnFamilyMetadata(tableInfo, cfDef, cfProperties); } setColumnFamilyProperties(cfDef, cfProperties, null); return cfDef; }
/** * Validate compound key. * * @param tableInfo * the table info */ private void validateCompoundKey(TableInfo tableInfo) { if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { throw new SchemaGenerationException( "Composite/Compound columns are not yet supported over Super column family by Cassandra", "cassandra", databaseName); } }