public boolean accepts(Geocognition geocog, GeocognitionElement element) { if (GeocognitionCustomQueryFactory.BUILT_IN_QUERY_ID.equals(element.getTypeId())) { String registered = element.getProperties().get(GeocognitionBuiltInCustomQuery.REGISTERED); if ((registered != null) && registered.equals(GeocognitionBuiltInCustomQuery.IS_NOT_REGISTERED)) { return true; } else { return false; } } else { return false; } }
@SuppressWarnings("unchecked") public void execute(Geocognition geocognition, GeocognitionElement element) { if (GeocognitionCustomQueryFactory.BUILT_IN_QUERY_ID.equals(element.getTypeId())) { Class<? extends CustomQuery> queryClass = (Class<? extends CustomQuery>) element.getObject(); try { QueryManager.remove(queryClass.newInstance().getName()); QueryManager.registerQuery(queryClass); } catch (InstantiationException e) { Services.getService(ErrorManager.class).error("Bug!", e); } catch (IllegalAccessException e) { Services.getService(ErrorManager.class).error("Bug!", e); } } }