本文整理汇总了Java中org.geomajas.command.CommandResponse类的典型用法代码示例。如果您正苦于以下问题:Java CommandResponse类的具体用法?Java CommandResponse怎么用?Java CommandResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandResponse类属于org.geomajas.command包,在下文中一共展示了CommandResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: goToLocation
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
public void goToLocation(final CommandResponse commandResponse, final String location) {
if (commandResponse instanceof GetLocationForStringResponse) {
GetLocationForStringResponse response = (GetLocationForStringResponse) commandResponse;
if (response.isLocationFound()) {
removeAltWindow();
handlerManager.fireEvent(new SelectLocationEvent(map, response));
} else {
List<GetLocationForStringAlternative> alternatives = response.getAlternatives();
if (null != alternatives && alternatives.size() > 0) {
handlerManager.fireEvent(new SelectAlternativeEvent(map, alternatives));
} else {
SC.say(messages.locationNotFound(location));
}
}
}
}
示例2: onCommandException
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Override
public void onCommandException(CommandResponse response) {
String message = "";
List<String> msgs = response.getErrorMessages();
for (int i = 0; i < msgs.size(); i++) {
if (i == 0) {
message += msgs.get(i);
} else {
message += "- " + msgs.get(i);
}
if (i < msgs.size() - 1) {
message += "<br />";
}
}
addMessage(message, ERRORMESSAGE_STYLE);
}
示例3: onGenerateExceptionClicked
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@UiHandler("generateExceptionButton")
protected void onGenerateExceptionClicked(ClickEvent event) {
EmptyCommandRequest request = new EmptyCommandRequest();
GwtCommand command = new GwtCommand();
command.setCommandName("command.GetSimpleExceptionCommand");
command.setCommandRequest(request);
GeomajasServerExtension.getInstance().getCommandService()
.execute(command, new AbstractCommandCallback<CommandResponse>() {
@Override
public void execute(CommandResponse response) {
// don't do anything. An Exception will been thrown at
// server-side
}
});
}
示例4: testLogAllowed
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void testLogAllowed() throws Exception {
LoginRequest request = new LoginRequest();
request.setLogin("luc");
request.setPassword("luc");
CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, null);
Assert.assertTrue(response instanceof LoginResponse);
Assert.assertFalse(response.isError());
String token = ((LoginResponse)response).getToken();
Assert.assertNotNull(token);
Assert.assertNull(securityContext.getToken());
LogRequest logRequest = new LogRequest();
logRequest.setStatement("test log command access");
response = commandDispatcher.execute(LogRequest.COMMAND, logRequest, token, "en");
Assert.assertFalse(response.isError());
Assert.assertNull(securityContext.getToken());
// this test to verify the command itself (should fail here as "luc" should be logged in).
response = commandDispatcher.execute("command.MarinoLoggedIn", null, token, "en");
Assert.assertTrue(response.isError());
Assert.assertTrue(response.getErrors().get(0) instanceof GeomajasException);
Assert.assertEquals(ExceptionCode.TEST, ((GeomajasException)response.getErrors().get(0)).getExceptionCode());
Assert.assertNull(securityContext.getToken());
}
示例5: testLogNotAllowed
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void testLogNotAllowed() throws Exception {
LoginRequest request = new LoginRequest();
request.setLogin("marino");
request.setPassword("marino");
CommandResponse response = commandDispatcher.execute(LoginRequest.COMMAND, request, null, null);
Assert.assertTrue(response instanceof LoginResponse);
Assert.assertFalse(response.isError());
String token = ((LoginResponse)response).getToken();
Assert.assertNotNull(token);
Assert.assertNull(securityContext.getToken());
LogRequest logRequest = new LogRequest();
logRequest.setStatement("test log command access");
response = commandDispatcher.execute("command.general.Log", logRequest, token, "en");
Assert.assertTrue(response.isError());
Assert.assertEquals("User marino is not authorized to use the command command.general.Log.",
response.getErrorMessages().get(0)); // needs to be updated when messages file is changed
Assert.assertNull(securityContext.getToken());
response = commandDispatcher.execute("command.MarinoLoggedIn", null, token, "en");
Assert.assertFalse(response.isError());
Assert.assertNull(securityContext.getToken());
}
示例6: testGetConfigurationFilterToolsAndInvisibleLayers
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void testGetConfigurationFilterToolsAndInvisibleLayers() throws Exception {
login("luc");
GetMapConfigurationRequest request = new GetMapConfigurationRequest();
request.setApplicationId(APP_ID);
request.setMapId(MAP_ID);
CommandResponse response = commandDispatcher.execute(GetMapConfigurationRequest.COMMAND, request,
securityContext.getToken(), "en");
Assert.assertFalse(response.isError());
Assert.assertTrue(response instanceof GetMapConfigurationResponse);
ClientMapInfo mapInfo = ((GetMapConfigurationResponse)response).getMapInfo();
Assert.assertEquals(MAP_ID, mapInfo.getId());
Assert.assertEquals("EPSG:4326", mapInfo.getCrs());
ClientToolbarInfo toolbar = mapInfo.getToolbar();
Assert.assertNotNull(toolbar);
Assert.assertEquals("toolbar", toolbar.getId());
Assert.assertEquals(1, toolbar.getTools().size());
Assert.assertEquals("ZoomToSelection", toolbar.getTools().get(0).getId());
List<ClientLayerInfo> layers = mapInfo.getLayers();
Assert.assertEquals(0, layers.size());
}
示例7: testLoginAllowed
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
/**
* Test using custom authentication service credentials.
*
* @throws Exception oops
*/
@Test
public void testLoginAllowed() throws Exception {
LoginRequest request = new LoginRequest();
request.setLogin("custom");
request.setPassword("custom");
CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, null);
Assert.assertTrue(response instanceof LoginResponse);
Assert.assertFalse(response.isError());
String token = ((LoginResponse)response).getToken();
Assert.assertNotNull(token);
Assert.assertNull(securityContext.getToken());
LogRequest logRequest = new LogRequest();
logRequest.setStatement("test log command access");
response = commandDispatcher.execute(LogRequest.COMMAND, logRequest, token, "en");
Assert.assertFalse(response.isError());
Assert.assertNull(securityContext.getToken());
}
示例8: testLoginChainingDefault
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
/**
* The default handling should also be added automatically, so logging in using the passed user info should
* also work.
*
* @throws Exception oops
*/
@Test
public void testLoginChainingDefault() throws Exception {
LoginRequest request = new LoginRequest();
request.setLogin("luc");
request.setPassword("luc");
CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, null);
Assert.assertTrue(response instanceof LoginResponse);
Assert.assertFalse(response.isError());
String token = ((LoginResponse)response).getToken();
Assert.assertNotNull(token);
Assert.assertNull(securityContext.getToken());
LogRequest logRequest = new LogRequest();
logRequest.setStatement("test log command access");
response = commandDispatcher.execute(LogRequest.COMMAND, logRequest, token, "en");
Assert.assertFalse(response.isError());
Assert.assertNull(securityContext.getToken());
}
示例9: dispatchedTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void dispatchedTest() throws Exception {
// login
LoginRequest login = new LoginRequest();
login.setLogin("luc");
login.setPassword("luc");
LoginResponse loginResponse = (LoginResponse) dispatcher.execute(LoginRequest.COMMAND, login, null, "en");
String token = loginResponse.getToken();
GetUsersRequest request = new GetUsersRequest();
CommandResponse response = dispatcher.execute(GetUsersRequest.COMMAND, request, token, "en");
if (response.isError()) {
response.getErrors().get(0).printStackTrace();
}
Assert.assertFalse(response.isError());
Assert.assertTrue(response instanceof GetUsersResponse);
checkResult((GetUsersResponse) response);
// now logout
dispatcher.execute(LogoutRequest.COMMAND, null, token, "en");
}
示例10: testSearchByPoint
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void testSearchByPoint() throws Exception {
String layer = "layerWmsCountries";
SearchByPointRequest request = new SearchByPointRequest();
request.setBbox(new Bbox(-3211986.0066263545, 98246.25012821658, 1.065471024672729E7, 3365675.229452881));
request.setCrs("EPSG:900913");
Map<String, String> layers = new HashMap<String, String>();
layers.put(layer, layer);
request.setLayerMapping(layers);
request.setLocation(new Coordinate(672238.022713162, 2554015.0948743597));
request.setScale(1.022083167709322E-4);
CommandResponse response = dispatcher.execute(SearchByPointRequest.COMMAND, request, null, "en");
Assert.assertFalse(response.isError());
Assert.assertTrue(response instanceof SearchByPointResponse);
SearchByPointResponse sbp = (SearchByPointResponse) response;
Map<String, List<Feature>> map = sbp.getFeatureMap();
Assert.assertNotNull(map);
List<Feature> features = map.get(layer);
Assert.assertEquals(1, features.size());
Feature feature = features.get(0);
Assert.assertEquals("belt.2", feature.getId());
Assert.assertEquals("Tropical", feature.getAttributes().get("BELT").getValue());
Assert.assertEquals("2", feature.getAttributes().get("FID").getValue());
}
示例11: expandPointTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void expandPointTest() throws Exception {
GetLocationForStringRequest request = new GetLocationForStringRequest();
request.setCrs("EPSG:900913");
request.setLocation("booischot");
CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
"en");
Assert.assertNotNull(commandResponse);
Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
Assert.assertTrue(response.isLocationFound());
Assert.assertEquals("booischot", response.getCanonicalLocation());
Assert.assertNotNull(response.getCenter());
Assert.assertNotNull(response.getBbox());
Assert.assertEquals(621468.063486916, response.getCenter().getX(), DELTA);
Assert.assertEquals(5706881.117852388, response.getCenter().getY(), DELTA);
Assert.assertEquals(621325.5343735645, response.getBbox().getX(), DELTA);
Assert.assertEquals(5706809.617868648, response.getBbox().getY(), DELTA);
Assert.assertEquals(285.05822670296766, response.getBbox().getWidth(), DELTA);
Assert.assertEquals(142.99996748007834, response.getBbox().getHeight(), DELTA);
Assert.assertEquals("static-regex", response.getGeocoderName());
Assert.assertNotNull(response.getUserData());
Assert.assertEquals("schotbooi", ((UserDataTestInfo)response.getUserData()).getValue());
}
示例12: crsTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void crsTest() throws Exception {
GetLocationForStringRequest request = new GetLocationForStringRequest();
request.setCrs("EPSG:4326");
request.setLocation("Booischot");
CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
"en");
Assert.assertNotNull(commandResponse);
Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
Assert.assertTrue(response.isLocationFound());
Assert.assertEquals("Booischot", response.getCanonicalLocation());
Assert.assertNotNull(response.getCenter());
Assert.assertNotNull(response.getBbox());
Assert.assertEquals(5.582742600224577, response.getCenter().getX(), DELTA);
Assert.assertEquals(45.53964302945367, response.getCenter().getY(), DELTA);
}
示例13: secondServiceTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void secondServiceTest() throws Exception {
GetLocationForStringRequest request = new GetLocationForStringRequest();
request.setCrs("EPSG:900913");
request.setLocation("second");
CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
"en");
Assert.assertNotNull(commandResponse);
Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
Assert.assertTrue(response.isLocationFound());
Assert.assertEquals("secondService", response.getCanonicalLocation());
Assert.assertNotNull(response.getCenter());
Assert.assertNotNull(response.getBbox());
Assert.assertEquals(10000, response.getCenter().getX(), DELTA);
Assert.assertEquals(10000, response.getCenter().getY(), DELTA);
Assert.assertEquals("static-regex", response.getGeocoderName());
Assert.assertNull(response.getUserData());
}
示例14: bboxTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void bboxTest() throws Exception {
GetLocationForStringRequest request = new GetLocationForStringRequest();
request.setCrs("EPSG:900913");
request.setLocation("bbox");
CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
"en");
Assert.assertNotNull(commandResponse);
Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
Assert.assertTrue(response.isLocationFound());
Assert.assertEquals("bbox", response.getCanonicalLocation());
Assert.assertNotNull(response.getCenter());
Assert.assertNotNull(response.getBbox());
Assert.assertEquals(50000, response.getCenter().getX(), DELTA);
Assert.assertEquals(90000, response.getCenter().getY(), DELTA);
Assert.assertEquals(0, response.getBbox().getX(), DELTA);
Assert.assertEquals(50000, response.getBbox().getY(), DELTA);
Assert.assertEquals(100000, response.getBbox().getWidth(), DELTA);
Assert.assertEquals(80000, response.getBbox().getHeight(), DELTA);
Assert.assertEquals("static-regex", response.getGeocoderName());
Assert.assertNull(response.getUserData());
}
示例15: combineBboxTest
import org.geomajas.command.CommandResponse; //导入依赖的package包/类
@Test
public void combineBboxTest() throws Exception {
GetLocationForStringRequest request = new GetLocationForStringRequest();
request.setCrs("EPSG:900913");
request.setLocation("bla");
CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
"en");
Assert.assertNotNull(commandResponse);
Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
Assert.assertTrue(response.isLocationFound());
Assert.assertEquals("bla", response.getCanonicalLocation());
Assert.assertNotNull(response.getCenter());
Assert.assertNotNull(response.getBbox());
Assert.assertEquals(57500, response.getCenter().getX(), DELTA);
Assert.assertEquals(72500, response.getCenter().getY(), DELTA);
Assert.assertEquals(30000, response.getBbox().getX(), DELTA);
Assert.assertEquals(50000, response.getBbox().getY(), DELTA);
Assert.assertEquals(55000, response.getBbox().getWidth(), DELTA);
Assert.assertEquals(45000, response.getBbox().getHeight(), DELTA);
Assert.assertNull(response.getGeocoderName());
}