/** * Creates an object from the JSON string * */ public static DestinationsViewFilter create(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); if (json == null) { return new DestinationsViewFilter(); } json = json.trim(); if (json.length() == 0 || json.equals("{}")) { return new DestinationsViewFilter(); } return mapper.readerFor(DestinationsViewFilter.class).readValue(json); }
@Override public String queryQueues(String filter, int page, int pageSize) throws IOException { return DestinationsViewFilter.create(filter) .setDestinations(safeGetBroker().getQueueViews()) .filter(page, pageSize); }
@Override public boolean apply(DestinationView input) { boolean match = true; if (getName() != null && !getName().isEmpty()) { match = input.getName().contains(getName()); } if (match) { if (getFilter().equals("empty")) { match = input.getQueueSize() == 0; } if (getFilter().equals("nonEmpty")) { match = input.getQueueSize() != 0; } if (getFilter().equals("noConsumer")) { match = input.getConsumerCount() == 0; } if (getFilter().equals("nonAdvisory")) { return !(input instanceof TopicView && AdvisorySupport.isAdvisoryTopic(new ActiveMQTopic(input.getName()))); } } return match; } };
/** * Filter, sort and page results. * * Returns JSON map with resulting destination views and total number of matched destinations * * @param page - defines result page to be returned * @param pageSize - defines page size to be used * @throws IOException */ String filter(int page, int pageSize) throws IOException { ObjectMapper mapper = new ObjectMapper(); destinations = Maps.filterValues(destinations, getPredicate()); Map<ObjectName, DestinationView> pagedDestinations = getPagedDestinations(page, pageSize); Map<String, Object> result = new HashMap<String, Object>(); result.put("data", pagedDestinations); result.put("count", destinations.size()); StringWriter writer = new StringWriter(); mapper.writeValue(writer, result); return writer.toString(); }
Map<ObjectName, DestinationView> getPagedDestinations(int page, int pageSize) { ImmutableMap.Builder<ObjectName, DestinationView> builder = ImmutableMap.builder(); int start = (page - 1) * pageSize; int end = Math.min(page * pageSize, destinations.size()); int i = 0; for (Map.Entry<ObjectName, DestinationView> entry : getOrdering().sortedCopy(destinations.entrySet())) { if (i >= start && i < end) { builder.put(entry.getKey(), entry.getValue()); } i++; } return builder.build(); }
/** * Filter, sort and page results. * * Returns JSON map with resulting destination views and total number of matched destinations * * @param page - defines result page to be returned * @param pageSize - defines page size to be used * @throws IOException */ String filter(int page, int pageSize) throws IOException { ObjectMapper mapper = new ObjectMapper(); destinations = Maps.filterValues(destinations, getPredicate()); Map<ObjectName, DestinationView> pagedDestinations = getPagedDestinations(page, pageSize); Map<String, Object> result = new HashMap<String, Object>(); result.put("data", pagedDestinations); result.put("count", destinations.size()); StringWriter writer = new StringWriter(); mapper.writeValue(writer, result); return writer.toString(); }
Map<ObjectName, DestinationView> getPagedDestinations(int page, int pageSize) { ImmutableMap.Builder<ObjectName, DestinationView> builder = ImmutableMap.builder(); int start = (page - 1) * pageSize; int end = Math.min(page * pageSize, destinations.size()); int i = 0; for (Map.Entry<ObjectName, DestinationView> entry : getOrdering().sortedCopy(destinations.entrySet())) { if (i >= start && i < end) { builder.put(entry.getKey(), entry.getValue()); } i++; } return builder.build(); }
@Override public String queryTopics(String filter, int page, int pageSize) throws IOException { return DestinationsViewFilter.create(filter) .setDestinations(safeGetBroker().getTopicViews()) .filter(page, pageSize); }
/** * Filter, sort and page results. * * Returns JSON map with resulting destination views and total number of matched destinations * * @param page - defines result page to be returned * @param pageSize - defines page size to be used * @throws IOException */ String filter(int page, int pageSize) throws IOException { ObjectMapper mapper = new ObjectMapper(); destinations = Maps.filterValues(destinations, getPredicate()); Map<ObjectName, DestinationView> pagedDestinations = getPagedDestinations(page, pageSize); Map<String, Object> result = new HashMap<String, Object>(); result.put("data", pagedDestinations); result.put("count", destinations.size()); StringWriter writer = new StringWriter(); mapper.writeValue(writer, result); return writer.toString(); }
@Override public boolean apply(DestinationView input) { boolean match = true; if (getName() != null && !getName().isEmpty()) { match = input.getName().contains(getName()); } if (match) { if (getFilter().equals("empty")) { match = input.getQueueSize() == 0; } if (getFilter().equals("nonEmpty")) { match = input.getQueueSize() != 0; } if (getFilter().equals("noConsumer")) { match = input.getConsumerCount() == 0; } if (getFilter().equals("nonAdvisory")) { return !(input instanceof TopicView && AdvisorySupport.isAdvisoryTopic(new ActiveMQTopic(input.getName()))); } } return match; } };
/** * Creates an object from the JSON string * */ public static DestinationsViewFilter create(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); if (json == null) { return new DestinationsViewFilter(); } json = json.trim(); if (json.length() == 0 || json.equals("{}")) { return new DestinationsViewFilter(); } return mapper.readerFor(DestinationsViewFilter.class).readValue(json); }
Map<ObjectName, DestinationView> getPagedDestinations(int page, int pageSize) { ImmutableMap.Builder<ObjectName, DestinationView> builder = ImmutableMap.builder(); int start = (page - 1) * pageSize; int end = Math.min(page * pageSize, destinations.size()); int i = 0; for (Map.Entry<ObjectName, DestinationView> entry : getOrdering().sortedCopy(destinations.entrySet())) { if (i >= start && i < end) { builder.put(entry.getKey(), entry.getValue()); } i++; } return builder.build(); }
@Override public String queryQueues(String filter, int page, int pageSize) throws IOException { return DestinationsViewFilter.create(filter) .setDestinations(safeGetBroker().getQueueViews()) .filter(page, pageSize); }
/** * Filter, sort and page results. * * Returns JSON map with resulting destination views and total number of matched destinations * * @param page - defines result page to be returned * @param pageSize - defines page size to be used * @throws IOException */ String filter(int page, int pageSize) throws IOException { ObjectMapper mapper = new ObjectMapper(); destinations = Maps.filterValues(destinations, getPredicate()); Map<ObjectName, DestinationView> pagedDestinations = getPagedDestinations(page, pageSize); Map<String, Object> result = new HashMap<String, Object>(); result.put("data", pagedDestinations); result.put("count", destinations.size()); StringWriter writer = new StringWriter(); mapper.writeValue(writer, result); return writer.toString(); }
@Override public boolean apply(DestinationView input) { boolean match = true; if (getName() != null && !getName().isEmpty()) { match = input.getName().contains(getName()); } if (match) { if (getFilter().equals("empty")) { match = input.getQueueSize() == 0; } if (getFilter().equals("nonEmpty")) { match = input.getQueueSize() != 0; } if (getFilter().equals("noConsumer")) { match = input.getConsumerCount() == 0; } if (getFilter().equals("nonAdvisory")) { return !(input instanceof TopicView && AdvisorySupport.isAdvisoryTopic(new ActiveMQTopic(input.getName()))); } } return match; } };
/** * Creates an object from the JSON string * */ public static DestinationsViewFilter create(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); if (json == null) { return new DestinationsViewFilter(); } json = json.trim(); if (json.length() == 0 || json.equals("{}")) { return new DestinationsViewFilter(); } return mapper.readerFor(DestinationsViewFilter.class).readValue(json); }
Map<ObjectName, DestinationView> getPagedDestinations(int page, int pageSize) { ImmutableMap.Builder<ObjectName, DestinationView> builder = ImmutableMap.builder(); int start = (page - 1) * pageSize; int end = Math.min(page * pageSize, destinations.size()); int i = 0; for (Map.Entry<ObjectName, DestinationView> entry : getOrdering().sortedCopy(destinations.entrySet())) { if (i >= start && i < end) { builder.put(entry.getKey(), entry.getValue()); } i++; } return builder.build(); }
@Override public String queryQueues(String filter, int page, int pageSize) throws IOException { return DestinationsViewFilter.create(filter) .setDestinations(safeGetBroker().getQueueViews()) .filter(page, pageSize); }
@Override public boolean apply(DestinationView input) { boolean match = true; if (getName() != null && !getName().isEmpty()) { match = input.getName().contains(getName()); } if (match) { if (getFilter().equals("empty")) { match = input.getQueueSize() == 0; } if (getFilter().equals("nonEmpty")) { match = input.getQueueSize() != 0; } if (getFilter().equals("noConsumer")) { match = input.getConsumerCount() == 0; } if (getFilter().equals("nonAdvisory")) { return !(input instanceof TopicView && AdvisorySupport.isAdvisoryTopic(new ActiveMQTopic(input.getName()))); } } return match; } };
/** * Creates an object from the JSON string * */ public static DestinationsViewFilter create(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); if (json == null) { return new DestinationsViewFilter(); } json = json.trim(); if (json.length() == 0 || json.equals("{}")) { return new DestinationsViewFilter(); } return mapper.readerFor(DestinationsViewFilter.class).readValue(json); }