Java Code Examples for java.util.SortedSet#addAll()

The following examples show how to use java.util.SortedSet#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexedInstances.java    From esigate with Apache License 2.0 6 votes vote down vote up
private Map<UriMapping, String> buildUriMappings() {
    Map<UriMapping, String> result = new LinkedHashMap<>();

    Map<UriMapping, String> unsortedResult = new LinkedHashMap<>();

    if (this.instances != null) {
        for (String instanceId : this.instances.keySet()) {
            List<UriMapping> driverMappings = this.instances.get(instanceId).getConfiguration().getUriMappings();

            for (UriMapping mapping : driverMappings) {
                unsortedResult.put(mapping, instanceId);
            }
        }
    }

    // Order according to weight.
    SortedSet<UriMapping> keys = new TreeSet<>(new UriMappingComparator());
    keys.addAll(unsortedResult.keySet());
    for (UriMapping key : keys) {
        result.put(key, unsortedResult.get(key));
    }

    return result;
}
 
Example 2
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Remove imageGallery item from HttpSession list and update page display. As authoring rule, all persist only
    * happen when user submit whole page. So this remove is just impact HttpSession values.
    */
   @RequestMapping("/removeImage")
   public String removeImage(HttpServletRequest request) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ImageGalleryConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(ImageGalleryConstants.PARAM_IMAGE_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<ImageGalleryItem> imageGalleryList = getImageList(sessionMap);
    List<ImageGalleryItem> rList = new ArrayList<>(imageGalleryList);
    ImageGalleryItem item = rList.remove(itemIdx);
    imageGalleryList.clear();
    imageGalleryList.addAll(rList);
    // add to delList
    List<ImageGalleryItem> delList = getDeletedImageGalleryItemList(sessionMap);
    delList.add(item);
}

request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return "pages/authoring/parts/itemlist";
   }
 
Example 3
Source File: ExpandTestState.java    From freerouting with GNU General Public License v3.0 6 votes vote down vote up
private void complete_autoroute()
{
    MazeSearchAlgo.Result search_result = this.maze_search_algo.find_connection();
    if (search_result != null)
    {
        SortedSet<Item> ripped_item_list = new TreeSet<Item>();
        this.autoroute_result =
                LocateFoundConnectionAlgo.get_instance(search_result, control_settings,
                this.autoroute_engine.autoroute_search_tree,
                hdlg.get_routing_board().rules.get_trace_angle_restriction(),
                ripped_item_list, eu.mihosoft.freerouting.board.TestLevel.ALL_DEBUGGING_OUTPUT);
        hdlg.get_routing_board().generate_snapshot();
        SortedSet<Item> ripped_connections = new TreeSet<Item>();
        for (Item curr_ripped_item : ripped_item_list)
        {
            ripped_connections.addAll(curr_ripped_item.get_connection_items(Item.StopConnectionOption.VIA));
        }
        hdlg.get_routing_board().remove_items(ripped_connections, false);
        InsertFoundConnectionAlgo.get_instance(autoroute_result, hdlg.get_routing_board(), control_settings);
    }
}
 
Example 4
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Ajax call, will add one more input line for new resource item instruction.
    */
   @RequestMapping("/initOverallFeedback")
   public String initOverallFeedback(HttpServletRequest request) {
SessionMap<String, Object> sessionMap = getSessionMap(request);
AssessmentForm assessmentForm = (AssessmentForm) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT_FORM);
Assessment assessment = assessmentForm.getAssessment();

// initial Overall feedbacks list
SortedSet<AssessmentOverallFeedback> overallFeedbackList = new TreeSet<>(new SequencableComparator());
if (!assessment.getOverallFeedbacks().isEmpty()) {
    overallFeedbackList.addAll(assessment.getOverallFeedbacks());
} else {
    for (int i = 1; i <= AssessmentConstants.INITIAL_OVERALL_FEEDBACK_NUMBER; i++) {
	AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
	if (i == 1) {
	    overallFeedback.setGradeBoundary(100);
	}
	overallFeedback.setSequenceId(i);
	overallFeedbackList.add(overallFeedback);
    }
}

request.setAttribute(AssessmentConstants.ATTR_OVERALL_FEEDBACK_LIST, overallFeedbackList);
return "pages/authoring/parts/overallfeedbacklist";
   }
 
Example 5
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Remove resource item from HttpSession list and update page display. As
    * authoring rule, all persist only happen when user submit whole page. So
    * this remove is just impact HttpSession values.
    */
   @RequestMapping(path = "/removeItem", method = RequestMethod.POST)
   private String removeItem(@ModelAttribute ResourceItemForm resourceItemForm, HttpServletRequest request) {
SessionMap<String, Object> sessionMap = getSessionMap(request);

@SuppressWarnings("deprecation")
int itemIdx = NumberUtils.stringToInt(request.getParameter(ResourceConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<ResourceItem> resourceList = getResourceItemList(sessionMap);
    List<ResourceItem> rList = new ArrayList<>(resourceList);
    ResourceItem item = rList.remove(itemIdx);
    resourceList.clear();
    resourceList.addAll(rList);
    // add to delList
    List<ResourceItem> delList = getDeletedResourceItemList(sessionMap);
    delList.add(item);
}

return "pages/authoring/parts/itemlist";
   }
 
Example 6
Source File: ServerGroupUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static SortedSet<String> getServerGroupsFromContainer(GemFireContainer container) {
  SortedSet<String> tableServerGroups = new TreeSet<String>();
  ExtraTableInfo    extraTableInfo    = container.getExtraTableInfo();
  TableDescriptor   tableDescriptor   = extraTableInfo.getTableDescriptor();
  try {
    DistributionDescriptor distributionDescriptor = tableDescriptor.getDistributionDescriptor(); // TODO Abhishek: when should we use this & why does it throw an exception?
    tableServerGroups.addAll(distributionDescriptor.getServerGroups());
  } catch (StandardException e) { // ignored - tableDescriptor.getDistributionDescriptor() is only an accessor method
  }

  return tableServerGroups;
}
 
Example 7
Source File: OchSignalTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Test
public void testToFlexgrid25() {
    OchSignal input = newDwdmSlot(CHL_25GHZ, 0);
    SortedSet<OchSignal> expected = newOchSignalTreeSet();
    expected.addAll(ImmutableList.of(
                newFlexGridSlot(-1),
                newFlexGridSlot(+1)));

    SortedSet<OchSignal> flexGrid = OchSignal.toFlexGrid(input);

    assertEquals(expected, flexGrid);
}
 
Example 8
Source File: PermanentViewerInfo.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private static SortedSet<PermanentViewerInfo> getLinked(final MagicGame game,final MagicPermanent permanent) {
    final SortedSet<PermanentViewerInfo> linked= new TreeSet<>(NAME_COMPARATOR);
    for (final MagicPermanent equipment : permanent.getEquipmentPermanents()) {
        linked.add(new PermanentViewerInfo(game,equipment));
        linked.addAll(getLinked(game, equipment));
    }
    for (final MagicPermanent aura : permanent.getAuraPermanents()) {
        linked.add(new PermanentViewerInfo(game,aura));
        linked.addAll(getLinked(game, aura));
    }
    return linked;
}
 
Example 9
Source File: UpdateTransactionCache_taddr.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
private void getAllSent(int limit, int offset, boolean rescan, long lastBlock, SortedSet<ZCashTransactionDetails_taddr> uniqueTransactions) throws ZCashException {
  List<ZCashTransactionDetails_taddr> nextPack;
  do {
    List<ZCashTransactionDetails_taddr> uncachedTransactions = new LinkedList<>();
    nextPack = getSentTransactions(pubKey, limit, offset);
    //Log.i("UPDATE CACHE:", String.format("Downloaded %d transactions", nextPack.size()));
    if (!rescan) {
      boolean cachedAll = true;
      for (ZCashTransactionDetails_taddr details : nextPack) {
        boolean cached = details.blockHeight <= lastBlock;
        if (!cached) {
          uncachedTransactions.add(details);
        }

        cachedAll &= details.blockHeight <= lastBlock;
      }

      if (cachedAll) {
        break;
      }
    } else {
      uncachedTransactions = nextPack;
    }

    uniqueTransactions.addAll(uncachedTransactions);
    Log.i("UPDATE CACHE:", String.format("Downloaded %d transactions", uniqueTransactions.size()));
    offset += limit;
  } while (nextPack.size() == limit);
}
 
Example 10
Source File: UpdateTransactionCache_taddr.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
private void getAllSent(int limit, int offset, boolean rescan, long lastBlock, SortedSet<ZCashTransactionDetails_taddr> uniqueTransactions) throws ZCashException {
  List<ZCashTransactionDetails_taddr> nextPack;
  do {
    List<ZCashTransactionDetails_taddr> uncachedTransactions = new LinkedList<>();
    nextPack = getSentTransactions(pubKey, limit, offset);
    //Log.i("UPDATE CACHE:", String.format("Downloaded %d transactions", nextPack.size()));
    if (!rescan) {
      boolean cachedAll = true;
      for (ZCashTransactionDetails_taddr details : nextPack) {
        boolean cached = details.blockHeight <= lastBlock;
        if (!cached) {
          uncachedTransactions.add(details);
        }

        cachedAll &= details.blockHeight <= lastBlock;
      }

      if (cachedAll) {
        break;
      }
    } else {
      uncachedTransactions = nextPack;
    }

    uniqueTransactions.addAll(uncachedTransactions);
    Log.i("UPDATE CACHE:", String.format("Downloaded %d transactions", uniqueTransactions.size()));
    offset += limit;
  } while (nextPack.size() == limit);
}
 
Example 11
Source File: RootCurriculumGroup.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CycleCurriculumGroup getLastOrderedCycleCurriculumGroup() {
    final SortedSet<CycleCurriculumGroup> cycleCurriculumGroups =
            new TreeSet<CycleCurriculumGroup>(CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID);
    cycleCurriculumGroups.addAll(getInternalCycleCurriculumGroups());

    return cycleCurriculumGroups.isEmpty() ? null : cycleCurriculumGroups.last();
}
 
Example 12
Source File: ProjectAssociationAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages({
    "ProjectAssociationAction.open_some_projects=Open some projects to choose from.",
    "ProjectAssociationAction.title_select_project=Select Project",
    "ProjectAssociationAction.could_not_associate=Failed to record a Hudson job association.",
    "ProjectAssociationAction.could_not_dissociate=Failed to find the Hudson job association to be removed."
})
@Override public void actionPerformed(ActionEvent e) {
    if (alreadyAssociatedProject == null) {
        SortedSet<Project> projects = new TreeSet<Project>(ProjectRenderer.comparator());
        projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
        if (projects.isEmpty()) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_open_some_projects(), NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }
        JComboBox box = new JComboBox(new DefaultComboBoxModel(projects.toArray(new Project[projects.size()])));
        box.setRenderer(new ProjectRenderer());
        if (DialogDisplayer.getDefault().notify(new NotifyDescriptor(box, Bundle.ProjectAssociationAction_title_select_project(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.PLAIN_MESSAGE, null, null)) != NotifyDescriptor.OK_OPTION) {
            return;
        }
        if (!ProjectHudsonProvider.getDefault().recordAssociation((Project) box.getSelectedItem(), assoc)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_associate(), NotifyDescriptor.WARNING_MESSAGE));
        }
    } else {
        if (!ProjectHudsonProvider.getDefault().recordAssociation(alreadyAssociatedProject, null)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_dissociate(), NotifyDescriptor.WARNING_MESSAGE));
        }
    }
}
 
Example 13
Source File: AssertionsImpl.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
private List<Node> getValues() {
	List<Node> result=new ArrayList<Node>();
	result.addAll(this.values);
	SortedSet<IndividualImpl> sortedLinks=new TreeSet<IndividualImpl>(new IndividualComparator());
	sortedLinks.addAll(links.values());
	for(IndividualImpl link:sortedLinks) {
		result.add(link.getIdentity());
	}
	return result;
}
 
Example 14
Source File: DegreeCandidacyManagementDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward showCandidacyDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixActionException, FenixServiceException {

    final StudentCandidacy candidacy = getCandidacy(request);
    request.setAttribute("candidacy", candidacy);

    final SortedSet<Operation> operations = new TreeSet<Operation>();
    operations.addAll(candidacy.getActiveCandidacySituation().getOperationsForPerson(getLoggedPerson(request)));
    request.setAttribute("operations", operations);

    request.setAttribute("person", getUserView(request).getPerson());
    return mapping.findForward("showCandidacyDetails");
}
 
Example 15
Source File: RouteMapSetAdditiveCommunityListLine.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public void applyTo(
    List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) {
  SortedSet<Long> communities = new TreeSet<>();
  for (String communityListName : _communityLists) {
    CommunityList communityList = c.getCommunityLists().get(communityListName);
    if (communityList != null) {
      StandardCommunityList scl = cc.getStandardCommunityLists().get(communityListName);
      if (scl != null) {
        for (StandardCommunityListLine line : scl.getLines()) {
          if (line.getAction() == LineAction.PERMIT) {
            communities.addAll(line.getCommunities());
          } else {
            w.redFlag(
                "Expected only permit lines in standard community-list referred to by route-map "
                    + "set community community-list line: \""
                    + communityListName
                    + "\"");
          }
        }
      } else {
        w.redFlag(
            "Expected standard community list in route-map set community community-list line "
                + "but got expanded instead: \""
                + communityListName
                + "\"");
      }
    }
  }
  _communityLists.forEach(
      communityListName ->
          statements.add(
              new AddCommunity(
                  new org.batfish.datamodel.routing_policy.expr.NamedCommunitySet(
                      communityListName))));
}
 
Example 16
Source File: BenchmarkResultsPrinter.java    From presto with Apache License 2.0 5 votes vote down vote up
private static List<String> getSelectedQueryTagNames(Iterable<Suite> suites, Iterable<BenchmarkQuery> queries)
{
    SortedSet<String> tags = new TreeSet<>();
    for (Suite suite : suites) {
        for (BenchmarkQuery query : suite.selectQueries(queries)) {
            tags.addAll(query.getTags().keySet());
        }

        for (RegexTemplate regexTemplate : suite.getSchemaNameTemplates()) {
            tags.addAll(regexTemplate.getFieldNames());
        }
    }
    return ImmutableList.copyOf(tags);
}
 
Example 17
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Remove taskList item from HttpSession list and update page display. As
    * authoring rule, all persist only happen when user submit whole page. So this
    * remove is just impact HttpSession values.
    */
   @RequestMapping("/removeItem")
   public String removeItem(HttpServletRequest request) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<TaskListItem> taskListList = getTaskListItemList(sessionMap);
    List<TaskListItem> rList = new ArrayList<>(taskListList);
    TaskListItem item = rList.remove(itemIdx);
    taskListList.clear();
    taskListList.addAll(rList);
    // add to delList
    List delList = getDeletedTaskListItemList(sessionMap);
    delList.add(item);

    // delete tasklistitems that still may be contained in Conditions
    SortedSet<TaskListCondition> conditionList = getTaskListConditionList(sessionMap);
    for (TaskListCondition condition : conditionList) {
	Set<TaskListItem> itemList = condition.getTaskListItems();
	if (itemList.contains(item)) {
	    itemList.remove(item);
	}
    }

}

request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return "pages/authoring/parts/itemlist";
   }
 
Example 18
Source File: UserPrefDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Transient
public Set<UserPrefEntryDO> getSortedUserPrefEntries()
{
  final SortedSet<UserPrefEntryDO> result = new TreeSet<UserPrefEntryDO>(new Comparator<UserPrefEntryDO>() {
    public int compare(final UserPrefEntryDO o1, final UserPrefEntryDO o2)
    {
      return StringHelper.compareTo(o1.orderString, o2.orderString);
    }
  });
  result.addAll(this.prefEntries);
  return result;
}
 
Example 19
Source File: ConfigParserImplConfig.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public void parseConfig() throws IOException {
    if ( LOG.isInfoEnabled() ) {
        LOG.info("Loading Rice configs: " + StringUtils.join(fileLocs, ", "));
    }
    Map<String, Object> baseObjects = getBaseObjects();
    if (baseObjects != null) {
        this.getObjects().putAll(baseObjects);
    }
    configureBuiltIns(getProperties());
    Properties baseProperties = getBaseProperties();
    if (baseProperties != null) {
        this.getProperties().putAll(baseProperties);
    }

    parseWithConfigParserImpl();
    //parseWithHierarchicalConfigParser();

    //if (!fileLocs.isEmpty()) {
    if ( LOG.isInfoEnabled() ) {
        LOG.info("");
        LOG.info("####################################");
        LOG.info("#");
        LOG.info("# Properties used after config override/replacement");
        LOG.info("# " + StringUtils.join(fileLocs, ", "));
        LOG.info("#");
        LOG.info("####################################");
        LOG.info("");
    }
    Map<String, String> safePropsUsed = ConfigLogger.getDisplaySafeConfig(this.propertiesUsed);
    Set<Map.Entry<String,String>> entrySet = safePropsUsed.entrySet();
    // sort it for display
    SortedSet<Map.Entry<String,String>>
            sorted = new TreeSet<Map.Entry<String,String>>(new Comparator<Map.Entry<String,String>>() {
        public int compare(Map.Entry<String,String> a, Map.Entry<String,String> b) {
            return a.getKey().compareTo(b.getKey());
        }
    });
    sorted.addAll(entrySet);
    //}
    if ( LOG.isInfoEnabled() ) {
        for (Map.Entry<String, String> propUsed: sorted) {
            LOG.info("Using config Prop " + propUsed.getKey() + "=[" + propUsed.getValue() + "]");
        }
    }
}
 
Example 20
Source File: TestTableMetadata.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Test
public void testAddPreviousMetadataRemoveOne() {
  long previousSnapshotId = System.currentTimeMillis() - new Random(1234).nextInt(3600);
  Snapshot previousSnapshot = new BaseSnapshot(
      ops.io(), previousSnapshotId, null, previousSnapshotId, null, null, ImmutableList.of(
      new GenericManifestFile(localInput("file:/tmp/manfiest.1.avro"), SPEC_5.specId())));
  long currentSnapshotId = System.currentTimeMillis();
  Snapshot currentSnapshot = new BaseSnapshot(
      ops.io(), currentSnapshotId, previousSnapshotId, currentSnapshotId, null, null, ImmutableList.of(
      new GenericManifestFile(localInput("file:/tmp/manfiest.2.avro"), SPEC_5.specId())));

  List<HistoryEntry> reversedSnapshotLog = Lists.newArrayList();
  long currentTimestamp = System.currentTimeMillis();
  List<MetadataLogEntry> previousMetadataLog = Lists.newArrayList();
  previousMetadataLog.add(new MetadataLogEntry(currentTimestamp - 100,
      "/tmp/000001-" + UUID.randomUUID().toString() + ".metadata.json"));
  previousMetadataLog.add(new MetadataLogEntry(currentTimestamp - 90,
      "/tmp/000002-" + UUID.randomUUID().toString() + ".metadata.json"));
  previousMetadataLog.add(new MetadataLogEntry(currentTimestamp - 80,
      "/tmp/000003-" + UUID.randomUUID().toString() + ".metadata.json"));
  previousMetadataLog.add(new MetadataLogEntry(currentTimestamp - 70,
      "/tmp/000004-" + UUID.randomUUID().toString() + ".metadata.json"));
  previousMetadataLog.add(new MetadataLogEntry(currentTimestamp - 60,
      "/tmp/000005-" + UUID.randomUUID().toString() + ".metadata.json"));

  MetadataLogEntry latestPreviousMetadata = new MetadataLogEntry(currentTimestamp - 50,
      "/tmp/000006-" + UUID.randomUUID().toString() + ".metadata.json");

  TableMetadata base = new TableMetadata(localInput(latestPreviousMetadata.file()), 1, UUID.randomUUID().toString(),
      TEST_LOCATION, 0, currentTimestamp - 50, 3, TEST_SCHEMA, 5,
      ImmutableList.of(SPEC_5), ImmutableMap.of("property", "value"), currentSnapshotId,
      Arrays.asList(previousSnapshot, currentSnapshot), reversedSnapshotLog,
      ImmutableList.copyOf(previousMetadataLog));

  previousMetadataLog.add(latestPreviousMetadata);

  TableMetadata metadata = base.replaceProperties(
      ImmutableMap.of(TableProperties.METADATA_PREVIOUS_VERSIONS_MAX, "5"));

  SortedSet<MetadataLogEntry> removedPreviousMetadata =
      Sets.newTreeSet(Comparator.comparingLong(MetadataLogEntry::timestampMillis));
  removedPreviousMetadata.addAll(base.previousFiles());
  removedPreviousMetadata.removeAll(metadata.previousFiles());

  Assert.assertEquals("Metadata logs should match", previousMetadataLog.subList(1, 6),
      metadata.previousFiles());
  Assert.assertEquals("Removed Metadata logs should contain 1", previousMetadataLog.subList(0, 1),
      ImmutableList.copyOf(removedPreviousMetadata));
}