本文整理汇总了Java中org.geomajas.command.dto.SearchFeatureRequest类的典型用法代码示例。如果您正苦于以下问题:Java SearchFeatureRequest类的具体用法?Java SearchFeatureRequest怎么用?Java SearchFeatureRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchFeatureRequest类属于org.geomajas.command.dto包,在下文中一共展示了SearchFeatureRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchOneCriterionOffset
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Test
public void testSearchOneCriterionOffset() throws Exception {
// prepare command
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
request.setMax(SearchFeatureRequest.MAX_UNLIMITED);
request.setOffSet(2);
SearchCriterion searchCriterion = new SearchCriterion();
searchCriterion.setAttributeName(REGION_ATTRIBUTE);
searchCriterion.setOperator("like");
searchCriterion.setValue("'%1'");
request.setCriteria(new SearchCriterion[] {searchCriterion});
// execute
SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
SearchFeatureRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(LAYER_ID, response.getLayerId());
List<Feature> features = Arrays.asList(response.getFeatures());
Assert.assertNotNull(features);
Assert.assertEquals(0, features.size());
}
示例2: testSearchNoCriteria
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Test
public void testSearchNoCriteria() throws Exception {
// prepare command
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
// execute
SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
SearchFeatureRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(LAYER_ID, response.getLayerId());
List<Feature> features = Arrays.asList(response.getFeatures());
Assert.assertNotNull(features);
Assert.assertEquals(4, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 1"));
Assert.assertTrue(actual.contains("Country 2"));
Assert.assertTrue(actual.contains("Country 3"));
Assert.assertTrue(actual.contains("Country 4"));
}
示例3: createFilterTest
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Test
@DirtiesContext // @todo need to check why this is necessary, otherwise next test fails? (GetVectorTileCommandTest)
// probably cause by directly using the command service which has an injected security context
public void createFilterTest() throws Exception {
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
SearchCriterion searchCriterion = new SearchCriterion();
Filter filter;
// needs to be FidFilter when equals test on id
searchCriterion.setAttributeName(ID_ATTRIBUTE);
searchCriterion.setOperator("=");
searchCriterion.setValue("'1'");
request.setCriteria(new SearchCriterion[] {searchCriterion});
filter = searchFeatureCommand.createFilter(request, LAYER_ID);
Assert.assertTrue(filter instanceof Id);
// but *not* when other test
searchCriterion.setAttributeName(ID_ATTRIBUTE);
searchCriterion.setOperator("like");
searchCriterion.setValue("'%a%'");
request.setCriteria(new SearchCriterion[] {searchCriterion});
filter = searchFeatureCommand.createFilter(request, LAYER_ID);
Assert.assertFalse(filter instanceof Id);
}
示例4: searchById
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
/**
* Search features within a certain layer, using the feature IDs.
*
* @param layer
* The features supported layer wherein to search.
* @param ids
* The unique IDs of the feature within the layer.
* @param callback
* Call-back method executed on return (when the feature has been found).
*/
public void searchById(final FeaturesSupported layer, final String[] ids, final FeatureArrayCallback callback) {
Layer<?> gwtLayer = map.getMapWidget().getMapModel().getLayer(layer.getId());
if (gwtLayer != null && gwtLayer instanceof VectorLayer) {
VectorLayer vLayer = (VectorLayer) gwtLayer;
SearchCriterion[] criteria = new SearchCriterion[ids.length];
for (int i = 0; i < ids.length; i++) {
criteria[i] = new SearchCriterion(SearchFeatureRequest.ID_ATTRIBUTE, "=", ids[i]);
}
SearchFeatureRequest request = new SearchFeatureRequest();
request.setBooleanOperator("OR");
request.setCrs(map.getMapWidget().getMapModel().getCrs());
request.setLayerId(vLayer.getServerLayerId());
request.setMax(ids.length);
request.setFilter(layer.getFilter());
request.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ALL);
request.setCriteria(criteria);
GwtCommand command = new GwtCommand(SearchFeatureRequest.COMMAND);
command.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<SearchFeatureResponse>() {
public void execute(SearchFeatureResponse response) {
if (response.getFeatures() != null && response.getFeatures().length > 0) {
Feature[] features = new Feature[response.getFeatures().length];
for (int i = 0; i < response.getFeatures().length; i++) {
features[i] = new FeatureImpl(response.getFeatures()[i], layer);
}
callback.execute(new FeatureArrayHolder(features));
}
}
});
}
}
示例5: setFeatures
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
public void setFeatures(List<Feature> features) {
this.features = features;
SearchFeatureRequest featReq = new SearchFeatureRequest();
featReq.setCriteria(buildCriteria());
featReq.setBooleanOperator("OR");
featReq.setCrs(model.getCrs());
featReq.setLayerId(layer.getServerLayerId());
featReq.setFilter(layer.getFilter());
featReq.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
setRequest(featReq);
}
示例6: getSearchFeatureRequest
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
protected SearchFeatureRequest getSearchFeatureRequest() {
if (request instanceof SearchFeatureRequest) {
return (SearchFeatureRequest) request;
} else {
return null;
}
}
示例7: setRequest
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
protected void setRequest(CommandRequest request) {
if (request instanceof SearchFeatureRequest || request instanceof SearchByLocationRequest) {
this.request = request;
} else {
throw new IllegalArgumentException(
"Please provide a request (SearchFeatureRequest or SearchByLocationRequest)");
}
}
示例8: search
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Override
public void search(String crs, final VectorServerLayer layer, SearchCriterion[] criteria,
LogicalOperator operator, int maxResultSize, final FeatureMapFunction callback) {
SearchFeatureRequest request = new SearchFeatureRequest();
request.setBooleanOperator(operator.getValue());
request.setCriteria(criteria);
request.setMax(maxResultSize);
request.setLayerId(layer.getServerLayerId());
request.setCrs(crs);
request.setFilter(layer.getFilter());
request.setFeatureIncludes(11);
GwtCommand command = new GwtCommand(SearchFeatureRequest.COMMAND);
command.setCommandRequest(request);
GeomajasServerExtension.getInstance().getCommandService().execute(command,
new AbstractCommandCallback<SearchFeatureResponse>() {
public void execute(SearchFeatureResponse response) {
List<Feature> features = new ArrayList<Feature>();
for (org.geomajas.layer.feature.Feature feature : response.getFeatures()) {
features.add(create(feature, layer));
}
Map<FeaturesSupported, List<Feature>> mapping = new HashMap<FeaturesSupported, List<Feature>>();
mapping.put(layer, features);
callback.execute(mapping);
}
});
}
示例9: execute
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Override
public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception {
String layerId = request.getLayerId();
if (null == layerId) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer");
}
String crs = request.getCrs();
if (null == crs) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs");
}
Filter filter = createFilter(request, layerId);
log.debug("filter to apply : {}", filter);
List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter,
null, request.getFeatureIncludes(), request.getOffSet(), request.getMax());
response.setLayerId(layerId);
int max = request.getMax();
if (max == SearchFeatureRequest.MAX_UNLIMITED) {
max = features.size();
}
if (max > features.size()) {
max = features.size();
}
Feature[] maxList = new Feature[max];
for (int i = 0; i < max; i++) {
Feature feature = converter.toDto(features.get(i));
feature.setCrs(crs);
maxList[i] = feature;
}
response.setFeatures(maxList);
}
示例10: testSearchOneCriterionNoLimit
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Test
public void testSearchOneCriterionNoLimit() throws Exception {
// prepare command
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
request.setMax(SearchFeatureRequest.MAX_UNLIMITED);
SearchCriterion searchCriterion = new SearchCriterion();
searchCriterion.setAttributeName(REGION_ATTRIBUTE);
searchCriterion.setOperator("like");
searchCriterion.setValue("'%1'");
request.setCriteria(new SearchCriterion[] {searchCriterion});
// execute
SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
SearchFeatureRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(LAYER_ID, response.getLayerId());
List<Feature> features = Arrays.asList(response.getFeatures());
Assert.assertNotNull(features);
Assert.assertEquals(2, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 1"));
Assert.assertTrue(actual.contains("Country 2"));
}
示例11: testSearchMultipleCriteria
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
@Test
public void testSearchMultipleCriteria() throws Exception {
// prepare command
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
SearchCriterion searchCriterion1 = new SearchCriterion();
searchCriterion1.setAttributeName(REGION_ATTRIBUTE);
searchCriterion1.setOperator("like");
searchCriterion1.setValue("'%egion 1'");
SearchCriterion searchCriterion2 = new SearchCriterion();
searchCriterion2.setAttributeName(REGION_ATTRIBUTE);
searchCriterion2.setOperator("like");
searchCriterion2.setValue("'%egion 2'");
request.setCriteria(new SearchCriterion[] {searchCriterion1, searchCriterion2});
request.setBooleanOperator("or");
// execute
SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
SearchFeatureRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(LAYER_ID, response.getLayerId());
List<Feature> features = Arrays.asList(response.getFeatures());
Assert.assertNotNull(features);
Assert.assertEquals(4, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 1"));
Assert.assertTrue(actual.contains("Country 2"));
Assert.assertTrue(actual.contains("Country 3"));
Assert.assertTrue(actual.contains("Country 4"));
}
示例12: getSearchFeatureRequest
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
public SearchFeatureRequest getSearchFeatureRequest() {
return searchFeatureRequest;
}
示例13: setSearchFeatureRequest
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
public void setSearchFeatureRequest(SearchFeatureRequest searchFeatureRequest) {
this.searchFeatureRequest = searchFeatureRequest;
}
示例14: getViewPanel
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
public Canvas getViewPanel() {
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
layout.setMembersMargin(10);
// switch off lazy loading, we want to get everything
GwtCommandDispatcher.getInstance().setUseLazyLoading(false);
VLayout mapLayout = new VLayout();
mapLayout.setShowEdges(true);
// Map with ID featureListGridMap is defined in the XML configuration.
final MapWidget map = new MapWidget("mapFeatureListGrid", "gwtExample");
map.setController(new SelectionController(map, 1000, 0.7f, false, 5));
mapLayout.addMember(map);
// Create a layout with a FeatureListGrid in it:
final FeatureListGrid grid = new FeatureListGrid(map.getMapModel());
grid.setShowEdges(true);
grid.setShowResizeBar(true);
// Add a trigger to fill the grid when the map has finished loading:
map.getMapModel().runWhenInitialized(new Runnable() {
public void run() {
final VectorLayer layer = map.getMapModel().getVectorLayer("clientLayerCountries110mGrid");
grid.setLayer(layer);
SearchFeatureRequest searchFeatureRequest = new SearchFeatureRequest();
searchFeatureRequest.setCrs(map.getMapModel().getCrs());
searchFeatureRequest.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ATTRIBUTES);
searchFeatureRequest.setLayerId("layerCountries110m");
GwtCommand searchCommand = new GwtCommand(SearchFeatureRequest.COMMAND);
searchCommand.setCommandRequest(searchFeatureRequest);
GwtCommandDispatcher.getInstance().execute(searchCommand,
new AbstractCommandCallback<SearchFeatureResponse>() {
public void execute(SearchFeatureResponse response) {
for (org.geomajas.layer.feature.Feature feature : response.getFeatures()) {
grid.addFeature(new Feature(feature, layer));
}
}
});
}
});
layout.addMember(grid);
layout.addMember(mapLayout);
return layout;
}
示例15: getViewPanel
import org.geomajas.command.dto.SearchFeatureRequest; //导入依赖的package包/类
public Canvas getViewPanel() {
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
layout.setMembersMargin(10);
// switch off lazy loading, we want to get everything
GwtCommandDispatcher.getInstance().setUseLazyLoading(false);
VLayout mapLayout = new VLayout();
mapLayout.setShowEdges(true);
// Map with ID featureListGridMap is defined in the XML configuration.
final MapWidget map = new MapWidget("mapEditableGrid", "gwtExample");
map.setController(new PanController(map));
mapLayout.addMember(map);
// Create a layout with a FeatureListGrid in it:
final FeatureListGrid grid = new FeatureListGrid(map.getMapModel());
grid.setShowEdges(true);
grid.setShowResizeBar(true);
grid.setEditingEnabled(true);
// Add a trigger to fill the grid when the map has finished loading:
map.getMapModel().runWhenInitialized(new Runnable() {
@Override
public void run() {
final VectorLayer layer = map.getMapModel().getVectorLayer("clientLayerBeansEditableGrid");
grid.setLayer(layer);
SearchFeatureRequest searchFeatureRequest = new SearchFeatureRequest();
searchFeatureRequest.setCrs(map.getMapModel().getCrs());
searchFeatureRequest.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ATTRIBUTES);
searchFeatureRequest.setLayerId("layerBeansEditableGrid");
GwtCommand searchCommand = new GwtCommand(SearchFeatureRequest.COMMAND);
searchCommand.setCommandRequest(searchFeatureRequest);
GwtCommandDispatcher.getInstance().execute(searchCommand,
new AbstractCommandCallback<SearchFeatureResponse>() {
public void execute(SearchFeatureResponse response) {
for (org.geomajas.layer.feature.Feature feature : response.getFeatures()) {
Feature f = new Feature(feature, layer);
grid.addFeature(f);
layer.getFeatureStore().addFeature(f);
}
}
}
);
}
});
layout.addMember(grid);
layout.addMember(mapLayout);
return layout;
}