org.eclipse.collections.impl.list.mutable.ListAdapter Java Examples

The following examples show how to use org.eclipse.collections.impl.list.mutable.ListAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<DaUserType> searchUserTypes(final DaSchema schema, Connection conn) throws SQLException {
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn,
            "SELECT s1.name as USER_TYPE_NAME\n" +
                    "FROM " + schema.getName() + "..systypes s1\n" +
                    "    , " + schema.getName() + "..sysusers sch\n" +
                    "WHERE s1.usertype>100 " +
                    "AND s1.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "' "
            , new MapListHandler()
    )).toImmutable();

    return maps.collect(new Function<Map<String, Object>, DaUserType>() {
        @Override
        public DaUserType valueOf(Map<String, Object> map) {
            return new DaUserTypeImpl((String) map.get("USER_TYPE_NAME"), schema);
        }
    });
}
 
Example #2
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private List<String> detectNotFullDependentObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType)
{
    final List<String> notFullClassNames = FastList.newList();
    MutableListMultimap<String,DependentLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getDependentLoaders()).groupBy(new Function<DependentLoaderType, String>()
    {
        @Override
        public String valueOf(final DependentLoaderType dependentLoaderType)
        {
            final String className = dependentLoaderType.getRelationship().substring(0, dependentLoaderType.getRelationship().lastIndexOf("."));
            MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(className);
            if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull())
            {
                notFullClassNames.add(dependentLoaderType.getRelationship());
            }
            return dependentLoaderType.getRelationship() + dependentLoaderType.getHelperFactoryClass();
        }
    });
    RichIterable<RichIterable<DependentLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1));
    this.assertEmpty("Found duplicates in Dependent Relationship:" + this.printListOfDependentLoaderType(listOfDupes), listOfDupes.toList());
    return notFullClassNames;
}
 
Example #3
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private List<String> detectNotFullTopLevelObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType)
{
    final List<String> notFullClassNames = FastList.newList();

    MutableListMultimap<String,TopLevelLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getTopLevelLoaders()).groupBy(new Function<TopLevelLoaderType, String>()
    {
        @Override
        public String valueOf(final TopLevelLoaderType topLevelLoaderType)
        {
            MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(topLevelLoaderType.getClassToLoad());
            if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull())
            {
                notFullClassNames.add(topLevelLoaderType.getClassToLoad());
            }
            return topLevelLoaderType.getClassToLoad() + topLevelLoaderType.getSourceAttributes() + topLevelLoaderType.getFactoryClass();
        }
    });
    RichIterable<RichIterable<TopLevelLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1));
    this.assertEmpty("Found duplicates in TopLevel Loader:" + this.printListOfTopLevelLoaderType(listOfDupes), listOfDupes.toList());

    return notFullClassNames;
}
 
Example #4
Source File: PlatformConfiguration.java    From obevo with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the default name-to-platform mappings. We put this in a separate protected method to allow external
 * distributions to override these values as needed.
 */
private ImmutableMap<String, ImmutableHierarchicalConfiguration> getDbPlatformMap() {
    final String platformKey = "db.platforms";

    ListIterable<ImmutableHierarchicalConfiguration> platformConfigs = ListAdapter.adapt(config.immutableChildConfigurationsAt("db.platforms"));

    MutableMap<String, ImmutableHierarchicalConfiguration> platformByName = Maps.mutable.empty();

    for (ImmutableHierarchicalConfiguration platformConfig : platformConfigs) {
        String platformName = platformConfig.getRootElementName();
        String platformClass = platformConfig.getString("class");
        if (platformClass == null) {
            LOG.warn("Improper platform config under {} for platform {}: missing class property. Will skip", platformKey, platformName);
        } else {
            platformByName.put(platformName, platformConfig);
            LOG.debug("Registering platform {} at class {}", platformName, platformClass);
        }
    }

    return platformByName.toImmutable();
}
 
Example #5
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<DaRule> searchRules(final DaSchema schema, Connection conn) throws SQLException {
    // Do not use ANSI JOIN as it does not work in Sybase 11.x - the SQL below works across all versions
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn,
            "SELECT rul.name as RULE_NAME\n" +
                    "FROM " + schema.getName() + "..sysobjects rul\n" +
                    "    , " + schema.getName() + "..sysusers sch\n" +
                    "WHERE rul.type = 'R'\n" +
                    "    and rul.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "' " +
                    "and not exists (\n" +
                    "\t-- Ensure that the entry is not attached to a table; otherwise, it is a regular table constraint, and will already be dropped when the table is dropped\n" +
                    "\tselect 1 from " + schema.getName() + "..sysconstraints c\n" +
                    "\twhere c.constrid = rul.id\n" +
                    ")\n",
            new MapListHandler()
    )).toImmutable();

    return maps.collect(new Function<Map<String, Object>, DaRule>() {
        @Override
        public DaRule valueOf(Map<String, Object> map) {
            return new DaRuleImpl((String) map.get("RULE_NAME"), schema);
        }
    });
}
 
Example #6
Source File: PostgresqlMetadataDialect.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<DaUserType> searchUserTypes(final DaSchema schema, Connection conn) {
    String sql = "SELECT t.typname \n" +
            "FROM        pg_type t \n" +
            "LEFT JOIN   pg_catalog.pg_namespace n ON n.oid = t.typnamespace \n" +
            "WHERE       (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) \n" +
            "AND     NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)\n" +
            "AND     n.nspname IN ('" + schema.getName() + "')";
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, sql, new MapListHandler())).toImmutable();

    return maps.collect(new Function<Map<String, Object>, DaUserType>() {
        @Override
        public DaUserType valueOf(Map<String, Object> map) {
            return new DaUserTypeImpl((String) map.get("typname"), schema);
        }
    });
}
 
Example #7
Source File: HsqlMetadataDialect.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<DaUserType> searchUserTypes(final DaSchema schema, Connection conn) throws SQLException {
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn,
            "select dom.DOMAIN_NAME AS USER_TYPE_NAME\n" +
                    "from INFORMATION_SCHEMA.DOMAINS dom\n" +
                    "WHERE dom.DOMAIN_SCHEMA = ucase('" + schema.getName() + "')\n",
            new MapListHandler()
    )).toImmutable();

    return maps.collect(new Function<Map<String, Object>, DaUserType>() {
        @Override
        public DaUserType valueOf(Map<String, Object> map) {
            return new DaUserTypeImpl((String) map.get("USER_TYPE_NAME"), schema);
        }
    });
}
 
Example #8
Source File: MsSqlMetadataDialect.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<DaRule> searchRules(final DaSchema schema, Connection conn) throws SQLException {
    // Do not use ANSI JOIN as it does not work in Sybase 11.x - the SQL below works across all versions
    String sql = "SELECT rul.name as RULE_NAME\n" +
            "FROM " + schema.getName() + "..sysobjects rul\n" +
            "    , sys.schemas sch\n" +
            "WHERE rul.type = 'R'\n" +
            "    and rul.uid = sch.schema_id and sch.name = '" + schema.getSubschemaName() + "' " +
            "and not exists (\n" +
            "\t-- Ensure that the entry is not attached to a table; otherwise, it is a regular table constraint, and will already be dropped when the table is dropped\n" +
            "\tselect 1 from " + schema.getName() + "..sysconstraints c\n" +
            "\twhere c.constid = rul.id\n" +
            ")\n";
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, sql, new MapListHandler())).toImmutable();

    return maps.collect(map -> new DaRuleImpl((String) map.get("RULE_NAME"), schema));
}
 
Example #9
Source File: CsvReaderDataSource.java    From obevo with Apache License 2.0 6 votes vote down vote up
/**
 * Putting this init here so that we can discover the file fields before running the actual rec
 */
public void init() {
    if (!this.initialized) {
        try {
            MutableList<String> fields;
            if (csvVersion == CsvStaticDataReader.CSV_V2) {
                CSVFormat csvFormat = CsvStaticDataReader.getCsvFormat(delim, nullToken);
                this.csvreaderV2 = new CSVParser(reader, csvFormat);
                this.iteratorV2 = csvreaderV2.iterator();
                fields = ListAdapter.adapt(IteratorUtils.toList(iteratorV2.next().iterator()));
            } else {
                this.csvreaderV1 = new au.com.bytecode.opencsv.CSVReader(this.reader, this.delim);
                fields = ArrayAdapter.adapt(this.csvreaderV1.readNext());
            }

            this.fields = fields.collect(this.convertDbObjectName);
        } catch (Exception e) {
            throw new DeployerRuntimeException(e);
        }
        this.initialized = true;
    }
}
 
Example #10
Source File: SameSchemaDbChecksumDao.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public ImmutableCollection<ChecksumEntry> getPersistedEntries(final PhysicalSchema physicalSchema) {
    return sqlExecutor.executeWithinContext(physicalSchema, new ThrowingFunction<Connection, ImmutableCollection<ChecksumEntry>>() {
        @Override
        public ImmutableCollection<ChecksumEntry> safeValueOf(Connection conn) throws Exception {
            return ListAdapter.adapt(jdbc.query(conn, "SELECT * FROM " + platform.getSchemaPrefix(physicalSchema) + checksumTableName, new MapListHandler())).collect(new Function<Map<String, Object>, ChecksumEntry>() {
                @Override
                public ChecksumEntry valueOf(Map<String, Object> result) {
                    return ChecksumEntry.createFromPersistence(
                            physicalSchema,
                            (String) result.get(objectTypeColumnName),
                            (String) result.get(objectName1ColumnName),
                            blankToNull((String) result.get(objectName2ColumnName)),
                            (String) result.get(checksumColumnName)
                    );
                }
            }).toImmutable();
        }
    });
}
 
Example #11
Source File: MsSqlMetadataDialect.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<DaUserType> searchUserTypes(final DaSchema schema, Connection conn) throws SQLException {
    String sql = "SELECT DOMAIN_NAME as USER_TYPE_NAME " +
            "FROM INFORMATION_SCHEMA.DOMAINS " +
            "WHERE DOMAIN_CATALOG = '" + schema.getName() + "' " +
            "AND DOMAIN_SCHEMA = '" + schema.getSubschemaName() + "'";
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, sql, new MapListHandler())).toImmutable();

    return maps.collect(map -> new DaUserTypeImpl((String) map.get("USER_TYPE_NAME"), schema));
}
 
Example #12
Source File: PackageMetadataReader.java    From obevo with Apache License 2.0 5 votes vote down vote up
private ImmutableMap<String, String> getSourceEncodings(ImmutableHierarchicalConfiguration metadataConfig) {
    MutableList<ImmutableHierarchicalConfiguration> encodingConfigs = ListAdapter.adapt(metadataConfig.immutableChildConfigurationsAt("sourceEncodings"));
    MutableMap<String, String> encodingsMap = Maps.mutable.empty();

    for (ImmutableHierarchicalConfiguration encodingConfig : encodingConfigs) {
        String fileList = encodingConfig.getString("");
        for (String file : fileList.split(",")) {
            encodingsMap.put(file, encodingConfig.getRootElementName());
        }
    }

    return encodingsMap.toImmutable();
}
 
Example #13
Source File: DaIndexImpl.java    From obevo with Apache License 2.0 5 votes vote down vote up
private DaIndexImpl(DependantObject<Table> index, List<? extends Column> columns, SchemaStrategy schemaStrategy, boolean unique, DaIndexType indexType) {
    this.index = Validate.notNull(index);
    Validate.notNull(schemaStrategy);
    this.columns = ListAdapter.adapt(columns)
            .collect((Function<Column, DaColumn>) object -> new DaColumnImpl(object, schemaStrategy))
            .toImmutable();
    this.schemaStrategy = Validate.notNull(schemaStrategy);
    this.unique = unique;
    this.indexType = indexType;
}
 
Example #14
Source File: DaTableImpl.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableList<DaColumn> getColumns() {
    return ListAdapter.adapt(table.getColumns()).collect(new Function<Column, DaColumn>() {
        @Override
        public DaColumn valueOf(Column object) {
            return (DaColumn) new DaColumnImpl(object, schemaStrategy);
        }
    }).toImmutable();
}
 
Example #15
Source File: DbPlatformConfiguration.java    From obevo with Apache License 2.0 5 votes vote down vote up
private ImmutableSet<String> createExtraEnvAttrs() {
    ListIterable<ImmutableHierarchicalConfiguration> extraEnvAttrs = ListAdapter.adapt(getConfig().immutableChildConfigurationsAt("extraEnvAttrs"));
    return extraEnvAttrs.collect(new Function<ImmutableHierarchicalConfiguration, String>() {
        @Override
        public String valueOf(ImmutableHierarchicalConfiguration c) {
            return c.getString("name");
        }
    }).toSet().toImmutable();
}
 
Example #16
Source File: DbEnvironmentXmlEnricherTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> constructMap(ImmutableNode node) {
        final Map<String, Object> map =
                new HashMap<>(node.getChildren().size());
        map.putAll(node.getAttributes());

        MutableListMultimap<String, ImmutableNode> nodesByName = ListAdapter.adapt(node.getChildren()).groupBy(new Function<ImmutableNode, String>() {
            @Override
            public String valueOf(ImmutableNode immutableNode) {
                return immutableNode.getNodeName();
            }
        });
        nodesByName.forEachKeyMultiValues(new Procedure2<String, Iterable<ImmutableNode>>() {
            @Override
            public void value(String nodeName, Iterable<ImmutableNode> nodeIterable) {
//            System.out.println("At node " + cNode.getNodeName() + " and attrs " + cNode.getAttributes() + " and value " + cNode.getValue() + " and children " + cNode.getChildren());
                MutableList<ImmutableNode> nodes = CollectionAdapter.wrapList(nodeIterable);
                if (nodes.size() > 1) {
                    map.put(nodeName, nodes.collect(new Function<ImmutableNode, Object>() {
                        @Override
                        public Object valueOf(ImmutableNode node1) {
                            return DbEnvironmentXmlEnricherTest.this.getNodeValue(node1);
                        }
                    }));
                } else {
                    map.put(nodeName, DbEnvironmentXmlEnricherTest.this.getNodeValue(nodes.getFirst()));
                }
            }
        });
        return map;
    }
 
Example #17
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<ExtraIndexInfo> searchExtraConstraintIndices(DaSchema schema, String tableName, Connection conn) throws SQLException {
    // Do not use ANSI JOIN as it does not work in Sybase 11.x - the SQL below works across all versions
    String tableClause = tableName == null ? "" : " AND tab.name = '" + tableName + "'";
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn,
            "select tab.name TABLE_NAME, ind.name INDEX_NAME, status2 & 8 IS_CONSTRAINT, status2 & 512 IS_CLUSTERED " +
                    "from " + schema.getName() + "..sysindexes ind" +
                    ", " + schema.getName() + "..sysobjects tab " +
                    ", " + schema.getName() + "..sysusers sch " +
                    "where ind.id = tab.id " +
                    "and tab.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
                    tableClause,
            new MapListHandler()
    )).toImmutable();

    return maps.collect(new Function<Map<String, Object>, ExtraIndexInfo>() {
        @Override
        public ExtraIndexInfo valueOf(Map<String, Object> map) {
            return new ExtraIndexInfo(
                    (String) map.get("TABLE_NAME"),
                    (String) map.get("INDEX_NAME"),
                    (Integer) map.get("IS_CONSTRAINT") != 0,
                    (Integer) map.get("IS_CLUSTERED") != 0
            );
        }
    });
}
 
Example #18
Source File: OracleMetadataDialect.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<DaUserType> searchUserTypes(final DaSchema schema, Connection conn) {
    String sql = "SELECT TYPE_NAME " +
            "FROM ALL_TYPES " +
            "WHERE OWNER = '" + schema.getName() + "'";
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, sql, new MapListHandler())).toImmutable();

    return maps.collect(new Function<Map<String, Object>, DaUserType>() {
        @Override
        public DaUserType valueOf(Map<String, Object> map) {
            return new DaUserTypeImpl((String) map.get("TYPE_NAME"), schema);
        }
    });
}
 
Example #19
Source File: Db2MetadataDialect.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<DaRoutine> searchExtraRoutines(final DaSchema schema, String procedureName, Connection conn) throws SQLException {
    String procedureClause = procedureName == null ? "" : " AND R.ROUTINENAME = '" + procedureName + "'";
    final String sql = "SELECT ROUTINENAME, SPECIFICNAME, TEXT FROM SYSCAT.ROUTINES R WHERE R.ROUTINETYPE = 'F'\n" +
            "AND R.ROUTINESCHEMA = '" + schema.getName() + "'\n" + procedureClause;
    LOG.debug("Executing function metadata query SQL: {}", sql);

    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn,
            sql,
            new MapListHandler()
    )).toImmutable();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Results:");
        for (Map<String, Object> map : maps) {
            LOG.debug("ROW: {}", map.toString());
        }
    }

    return maps.collect(map -> new DaRoutinePojoImpl(
            (String) map.get("ROUTINENAME"),
            schema,
            DaRoutineType.function,
            (String) map.get("SPECIFICNAME"),
            clobToString((Clob) map.get("TEXT"))
    ));
}
 
Example #20
Source File: MsSqlMetadataDialect.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<DaRoutine> searchExtraRoutines(final DaSchema schema, String procedureName, Connection conn) throws SQLException {
    String nameClause = procedureName != null ? " and ROUTINE_NAME = '" + procedureName + "'\n" : " ";

    String query = "SELECT" +
            "    ROUTINE_CATALOG," +
            "    ROUTINE_SCHEMA," +
            "    ROUTINE_NAME," +
            "    SPECIFIC_NAME," +
            "    ROUTINE_TYPE," +
            "    OBJECT_DEFINITION(OBJECT_ID(ROUTINE_CATALOG + '.' + ROUTINE_SCHEMA + '.' + ROUTINE_NAME)) AS ROUTINE_DEFINITION" +
            " FROM INFORMATION_SCHEMA.ROUTINES" +
            " WHERE ROUTINE_CATALOG = '" + schema.getName() + "'" +
            " AND ROUTINE_SCHEMA = '" + schema.getSubschemaName() + "'" +
            nameClause;
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, query, new MapListHandler())).toImmutable();

    return maps.collect(object -> {
        DaRoutineType routineType = DaRoutineType.valueOf(((String) object.get("ROUTINE_TYPE")).toLowerCase());
        return new DaRoutinePojoImpl(
                (String) object.get("ROUTINE_NAME"),
                schema,
                routineType,
                (String) object.get("SPECIFIC_NAME"),
                (String) object.get("ROUTINE_DEFINITION")
        );
    });
}
 
Example #21
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public ImmutableCollection<DaRoutine> searchExtraRoutines(final DaSchema schema, String procedureName, Connection conn) throws SQLException {
    String nameClause = procedureName != null ? "and obj.name = '" + procedureName + "'\n" : "";

    String query = String.format("select obj.name name, obj.type type, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "and obj.type in ('SF', 'P')\n" +
            nameClause +
            "order by com.id, number, colid2, colid\n", schema.getName());

    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> routineInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            String basename = (String) object.get("name");
            int number = ((Integer) object.get("number")).intValue();
            String specificName = number > 1 ? basename + ";" + number : basename;
            return new ExtraRerunnableInfo(
                    basename,
                    specificName,
                    (String) object.get("text"),
                    ((String) object.get("type")).trim(),
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return routineInfos.groupBy(ExtraRerunnableInfo.TO_SPECIFIC_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, DaRoutine>() {
        @Override
        public DaRoutine valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new DaRoutinePojoImpl(
                    sortedInfos.get(0).getName(),
                    schema,
                    sortedInfos.get(0).getType().equals("P") ? DaRoutineType.procedure : DaRoutineType.function,
                    sortedInfos.get(0).getSpecificName(),
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 
Example #22
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public ImmutableSet<String> getGroupNamesOptional(Connection conn, PhysicalSchema physicalSchema) throws SQLException {
    return ListAdapter.adapt(jdbc.query(conn, physicalSchema.getPhysicalName() + "..sp_helpgroup", new ColumnListHandler<String>("Group_name"))).toSet().toImmutable();
}
 
Example #23
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public ImmutableSet<String> getUserNamesOptional(Connection conn, PhysicalSchema physicalSchema) throws SQLException {
    return ListAdapter.adapt(jdbc.query(conn, physicalSchema.getPhysicalName() + "..sp_helpuser", new ColumnListHandler<String>("Users_name"))).toSet().toImmutable();
}
 
Example #24
Source File: SybaseAseMetadataDialect.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public ImmutableCollection<ExtraRerunnableInfo> searchExtraViewInfo(DaSchema schema, String tableName, Connection conn) throws SQLException {
    String query = String.format("select obj.name name, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.type in ('V')\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "order by com.id, number, colid2, colid\n", schema.getName());

    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(jdbc.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> viewInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            return new ExtraRerunnableInfo(
                    (String) object.get("name"),
                    null,
                    (String) object.get("text"),
                    null,
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return viewInfos.groupBy(ExtraRerunnableInfo.TO_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new ExtraRerunnableInfo(
                    sortedInfos.get(0).getName(),
                    null,
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 
Example #25
Source File: Db2PostDeployAction.java    From obevo with Apache License 2.0 4 votes vote down vote up
private MutableSet<SchemaObjectRow> queryNewInvalidObjects(Connection conn, String schemaInClause) {
    String sql = "SELECT OBJECTSCHEMA schema, OBJECTNAME name FROM SYSCAT.INVALIDOBJECTS WHERE OBJECTSCHEMA IN " + schemaInClause;
    return ListAdapter.adapt(this.stmtExecutor.getJdbcTemplate().query(conn, sql, new BeanListHandler<>(SchemaObjectRow.class))).toSet();
}
 
Example #26
Source File: Db2PostDeployAction.java    From obevo with Apache License 2.0 4 votes vote down vote up
private MutableSet<SchemaObjectRow> queryOldInvalidObjects(Connection conn, String schemaInClause) {
    String sql = "SELECT CREATOR schema, NAME name FROM SYSIBM.SYSTABLES WHERE TYPE = 'V' AND STATUS = 'X' AND CREATOR IN " + schemaInClause;
    return ListAdapter.adapt(this.stmtExecutor.getJdbcTemplate().query(conn, sql, new BeanListHandler<>(SchemaObjectRow.class))).toSet();
}
 
Example #27
Source File: AbstractEnvironmentEnricher.java    From obevo with Apache License 2.0 4 votes vote down vote up
protected static ImmutableList<ImmutableHierarchicalConfiguration> iterConfig(ImmutableHierarchicalConfiguration c, String path) {
    List<ImmutableHierarchicalConfiguration> list = c.immutableConfigurationsAt(path);
    return list != null ? ListAdapter.adapt(list).toImmutable() : Lists.immutable.<ImmutableHierarchicalConfiguration>empty();
}
 
Example #28
Source File: AbstractEnvironmentEnricher.java    From obevo with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<HierarchicalConfiguration> iterConfigMutable(HierarchicalConfiguration c, String path) {
    List<HierarchicalConfiguration> list = c.configurationsAt(path);
    return list != null ? ListAdapter.adapt(list).toImmutable() : Lists.immutable.<HierarchicalConfiguration>empty();
}
 
Example #29
Source File: AbstractEnvironmentEnricher.java    From obevo with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<String> iterListString(ImmutableHierarchicalConfiguration c, String path) {
    List<String> list = c.getList(String.class, path);
    return list != null ? ListAdapter.adapt(list).toImmutable() : Lists.immutable.<String>empty();
}
 
Example #30
Source File: IncrementalChangeTypeCommandCalculatorTest.java    From obevo with Apache License 2.0 4 votes vote down vote up
static Predicate<ChangeCommand> assertValue(final Class expectedClass, final Change expectedArtifact) {
    return command -> expectedClass.isAssignableFrom(command.getClass())
            && expectedArtifact.getObjectName().equals(ListAdapter.adapt(command.getChanges()).getFirst().getObjectName())
            && expectedArtifact.getChangeName().equals(ListAdapter.adapt(command.getChanges()).getFirst().getChangeName());
}