use of org.ff4j.property.Property in project ff4j by ff4j.
the class JdbcPropertyStore method readAllProperties.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Property<?>> readAllProperties() {
Map<String, Property<?>> properties = new LinkedHashMap<String, Property<?>>();
Connection sqlConn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
sqlConn = getDataSource().getConnection();
ps = buildStatement(sqlConn, getQueryBuilder().getAllProperties());
rs = ps.executeQuery();
while (rs.next()) {
Property<?> ap = JDBC_MAPPER.map(rs);
properties.put(ap.getName(), ap);
}
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot read properties within database, SQL ERROR", sqlEX);
} finally {
closeResultSet(rs);
closeStatement(ps);
closeConnection(sqlConn);
}
return properties;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreMongo method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
LinkedHashMap<String, Property<?>> mapP = new LinkedHashMap<>();
for (Document document : getPropertiesCollection().find()) {
Property<?> prop = PMAPPER.fromStore(document);
mapP.put(prop.getName(), prop);
}
return mapP;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreNeo4j method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
Map<String, Property<?>> allProperties = new HashMap<>();
Transaction tx = graphDb.beginTx();
// Node with relationships
Result result = graphDb.execute(QUERY_CYPHER_READ_ALLPROPERTIES);
while (result.hasNext()) {
Node node = (Node) result.next().get("p");
Property<?> current = Neo4jMapper.fromNode2Property(node);
allProperties.put(current.getName(), current);
}
tx.success();
return allProperties;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class InMemoryPropertyStoreTest method testInitStores.
@Test
public void testInitStores() {
new InMemoryPropertyStore(new HashMap<String, Property<?>>());
InputStream in = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
new InMemoryPropertyStore(in);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class InMemoryPropertyStoreTest method testInvalidXML.
@Test(expected = IllegalArgumentException.class)
public void testInvalidXML() {
new InMemoryPropertyStore(new HashMap<String, Property<?>>());
InputStream in = getClass().getClassLoader().getResourceAsStream("invalid.xml");
new InMemoryPropertyStore(in);
}
Aggregations