use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.
the class MissingSLDAttributes method checkAttributes.
/* (non-Javadoc)
* @see com.sldeditor.datasource.impl.CheckAttributeInterface#checkAttributes(com.sldeditor.datasource.SLDEditorFileInterface)
*/
@Override
public void checkAttributes(SLDEditorFileInterface editorFile) {
ExtractAttributes extract = new ExtractAttributes();
StyledLayerDescriptor sld = editorFile.getSLD();
extract.extractDefaultFields(sld);
List<DataSourceAttributeData> sldFieldList = extract.getFields();
List<DataSourceAttributeData> dataSourceList = editorFile.getSLDData().getFieldList();
for (DataSourceAttributeData sldField : sldFieldList) {
if (!dataSourceList.contains(sldField)) {
ConsoleManager.getInstance().error(this, Localisation.getField(DataSourceImpl.class, "DataSourceImpl.missingAttribute") + " " + sldField.getName());
}
}
}
use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.
the class ExtractAttributesTest method testIsLike.
@Test
public void testIsLike() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isLike
Filter filter = ff.like(ff.property("test"), "abcd1");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.
the class ExtractAttributesTest method testIsNull.
@Test
public void testIsNull() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isNull
Filter filter = ff.isNull(ff.property("test"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.
the class ExtractAttributesTest method testNonStandardGeometryField.
/**
* Test sld symbol contains non-default geometry field.
*
* {@link com.sldeditor.datasource.impl.ExtractAttributes#addDefaultFields(org.geotools.feature.simple.SimpleFeatureTypeBuilder, java.lang.String)}.
*/
@Test
public void testNonStandardGeometryField() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(SLDUtils.createSLDFromString(dummy.getSLDData()));
// Check fields extracted ok - should be none
List<String> expectedFieldList = dummy.getExpectedFieldList();
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertTrue(expectedFieldList.size() == actualFieldnameList.size());
assertEquals(0, actualFieldnameList.size());
// Check geometry fields extracted ok
List<String> actualGeometryFields = extract.getGeometryFields();
assertEquals(1, actualGeometryFields.size());
String expectedGeometryFieldName = dummy.getExpectedGeometryFieldList().get(0);
assertTrue(expectedGeometryFieldName.compareTo(actualGeometryFields.get(0)) == 0);
}
use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.
the class ExtractAttributesTest method testMultiComparatorFilter.
@Test
public void testMultiComparatorFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try with something complex
Filter filter = ff.and(ff.greater(ff.literal(42), ff.property("int")), ff.less(ff.literal(12), ff.property("abc")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(2, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
Aggregations