Search in sources :

Example 1 with UniqueProperty

use of io.syndesis.common.model.validation.UniqueProperty in project syndesis by syndesisio.

the class DataStoreConfiguration method jsonDB.

@Bean
@Autowired
@SuppressWarnings("PMD.EmptyCatchBlock")
public SqlJsonDB jsonDB(DBI dbi, Optional<List<Index>> beanIndexes) {
    ArrayList<Index> indexes = new ArrayList<>();
    if (beanIndexes.isPresent()) {
        indexes.addAll(beanIndexes.get());
    }
    for (Kind kind : Kind.values()) {
        addIndex(indexes, kind, kind.getModelClass().getAnnotation(UniqueProperty.class));
        UniqueProperty.Multiple ump = kind.getModelClass().getAnnotation(UniqueProperty.Multiple.class);
        if (ump != null) {
            for (UniqueProperty p : ump.value()) {
                addIndex(indexes, kind, p);
            }
        }
        addIndex(indexes, kind, kind.getModelClass().getAnnotation(IndexedProperty.class));
        IndexedProperty.Multiple imp = kind.getModelClass().getAnnotation(IndexedProperty.Multiple.class);
        if (imp != null) {
            for (IndexedProperty p : imp.value()) {
                addIndex(indexes, kind, p);
            }
        }
    }
    SqlJsonDB jsondb = new SqlJsonDB(dbi, null, indexes);
    try {
        jsondb.createTables();
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception ignore) {
        LOG.debug("Could not create tables", ignore);
    }
    return jsondb;
}
Also used : SqlJsonDB(io.syndesis.server.jsondb.impl.SqlJsonDB) IndexedProperty(io.syndesis.common.util.IndexedProperty) Kind(io.syndesis.common.model.Kind) ArrayList(java.util.ArrayList) Index(io.syndesis.server.jsondb.impl.Index) UniqueProperty(io.syndesis.common.model.validation.UniqueProperty) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Aggregations

Kind (io.syndesis.common.model.Kind)1 UniqueProperty (io.syndesis.common.model.validation.UniqueProperty)1 IndexedProperty (io.syndesis.common.util.IndexedProperty)1 Index (io.syndesis.server.jsondb.impl.Index)1 SqlJsonDB (io.syndesis.server.jsondb.impl.SqlJsonDB)1 ArrayList (java.util.ArrayList)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Bean (org.springframework.context.annotation.Bean)1