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

The following examples show how to use java.util.HashSet#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: AdminBrokerProcessor.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    QueryTopicConsumeByWhoRequestHeader requestHeader =
        (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);

    HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());

    Set<String> groupInOffset = this.brokerController.getConsumerOffsetManager().whichGroupByTopic(requestHeader.getTopic());
    if (groupInOffset != null && !groupInOffset.isEmpty()) {
        groups.addAll(groupInOffset);
    }

    GroupList groupList = new GroupList();
    groupList.setGroupList(groups);
    byte[] body = groupList.encode();

    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
Example 2
Source File: ForwardLookupInit.java    From yeti with MIT License 6 votes vote down vote up
private void btnLoadFromSourceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLoadFromSourceMouseClicked
        HashSet<String> domains = new HashSet<>();

        switch (cbxImportFrom.getSelectedIndex()) {
            case 0: {
                domains.addAll(DataStore.getDomains());
                domains.addAll(DataStore.getInitialDataItems(DataStore.DOMAIN));
                break;
            }
            case 1: {
                domains.addAll(DataStore.getInitialDataItems(DataStore.DOMAIN));
                break;
            }
            case 2: {

            }
        }

        for (String domain : domains) {
            this.txtDomains.append(domain + "\n");
        }

}
 
Example 3
Source File: NotebookRestApi.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
/**
 * Search for a Notes with permissions.
 */
@GET
@Path("search")
@ZeppelinApi
public Response search(@QueryParam("q") String queryTerm) {
  LOG.info("Searching notes for: {}", queryTerm);
  String principal = authenticationService.getPrincipal();
  Set<String> roles = authenticationService.getAssociatedRoles();
  HashSet<String> userAndRoles = new HashSet<>();
  userAndRoles.add(principal);
  userAndRoles.addAll(roles);
  List<Map<String, String>> notesFound = noteSearchService.query(queryTerm);
  for (int i = 0; i < notesFound.size(); i++) {
    String[] ids = notesFound.get(i).get("id").split("/", 2);
    String noteId = ids[0];
    if (!authorizationService.isOwner(noteId, userAndRoles) &&
        !authorizationService.isReader(noteId, userAndRoles) &&
        !authorizationService.isWriter(noteId, userAndRoles) &&
        !authorizationService.isRunner(noteId, userAndRoles)) {
      notesFound.remove(i);
      i--;
    }
  }
  LOG.info("{} notes found", notesFound.size());
  return new JsonResponse<>(Status.OK, notesFound).build();
}
 
Example 4
Source File: Props.java    From DataSphereStudio with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a set of all keys, including the parents
 */
public Set<String> getKeySet() {
  final HashSet<String> keySet = new HashSet<>();

  keySet.addAll(localKeySet());

  if (this._parent != null) {
    keySet.addAll(this._parent.getKeySet());
  }

  return keySet;
}
 
Example 5
Source File: ArrayIndexLivenessAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
protected void copy(Object source, Object dest)
{
    if (source == dest)
        return;
    
    HashSet sourceSet = (HashSet)source;
    HashSet destSet = (HashSet)dest;
    
    destSet.clear();
    destSet.addAll(sourceSet);
}
 
Example 6
Source File: URIRBLHandler.java    From james-project with Apache License 2.0 5 votes vote down vote up
/**
 * Recursively scans all MimeParts of an email for domain strings. Domain
 * strings that are found are added to the supplied HashSet.
 * 
 * @param part
 *            MimePart to scan
 * @param session
 *            not null
 * @return domains The HashSet that contains the domains which were
 *         extracted
 */
private HashSet<String> scanMailForDomains(MimePart part, SMTPSession session) throws MessagingException, IOException {
    HashSet<String> domains = new HashSet<>();
    LOGGER.debug("mime type is: \"{}\"", part.getContentType());

    if (part.isMimeType("text/plain") || part.isMimeType("text/html")) {
        LOGGER.debug("scanning: \"{}\"", part.getContent());
        HashSet<String> newDom = URIScanner.scanContentForDomains(domains, part.getContent().toString());

        // Check if new domains are found and add the domains
        if (newDom != null && newDom.size() > 0) {
            domains.addAll(newDom);
        }
    } else if (part.isMimeType("multipart/*")) {
        MimeMultipart multipart = (MimeMultipart) part.getContent();
        int count = multipart.getCount();
        LOGGER.debug("multipart count is: {}", count);

        for (int index = 0; index < count; index++) {
            LOGGER.debug("recursing index: {}", index);
            MimeBodyPart mimeBodyPart = (MimeBodyPart) multipart.getBodyPart(index);
            HashSet<String> newDomains = scanMailForDomains(mimeBodyPart, session);

            // Check if new domains are found and add the domains
            if (newDomains != null && newDomains.size() > 0) {
                domains.addAll(newDomains);
            }
        }
    }
    return domains;
}
 
Example 7
Source File: FieldSet.java    From flink with Apache License 2.0 5 votes vote down vote up
private FieldSet(FieldSet fieldSet1, FieldSet fieldSet2) {
	if (fieldSet2.size() == 0) {
		this.collection = fieldSet1.collection;
	}
	else if (fieldSet1.size() == 0) {
		this.collection = fieldSet2.collection;
	}
	else {
		HashSet<Integer> set = new HashSet<Integer>(2 * (fieldSet1.size() + fieldSet2.size()));
		set.addAll(fieldSet1.collection);
		set.addAll(fieldSet2.collection);
		this.collection = Collections.unmodifiableSet(set);
	}
}
 
Example 8
Source File: ProxyPreferencesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String[] childrenNames() throws BackingStoreException {
    synchronized (tree.treeLock()) {
        checkRemoved();
        HashSet<String> names = new HashSet<String>();
        if (delegate != null) {
            names.addAll(Arrays.asList(delegate.childrenNames()));
        }
        names.addAll(children.keySet());
        names.removeAll(removedChildren);
        return names.toArray(new String [names.size()]);
    }
}
 
Example 9
Source File: JoinedResourceProvider.java    From ThinkMap with Apache License 2.0 5 votes vote down vote up
@Override
public String[] getTextures() {
    HashSet<String> textures = new HashSet<>();
    for (ResourceProvider provider : providers) {
        textures.addAll(Arrays.asList(provider.getTextures()));
    }
    return textures.toArray(new String[textures.size()]);
}
 
Example 10
Source File: TimeStateSupport.java    From anno4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void addSourceDate(String sourceDate) {
    HashSet<String> sourceDates = new HashSet<>();

    Set<String> current = this.getSourceDates();

    if(current != null) {
        sourceDates.addAll(current);
    }

    sourceDates.add(sourceDate);
    this.setSourceDates(sourceDates);
}
 
Example 11
Source File: Student.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Deprecated
public Set<Exam> getExams(Integer examType) {
    HashSet exams = new HashSet();
    exams.addAll(new StudentDAO().getSession().createQuery(
            "select distinct o.exam from ExamOwner o, StudentClassEnrollment e "+
            "where e.student.uniqueId=:studentId and o.ownerType=:ownerType and o.ownerId=e.clazz.uniqueId and o.exam.examType.type=:examType")
            .setLong("studentId", getUniqueId())
            .setInteger("ownerType", ExamOwner.sOwnerTypeClass)
            .setInteger("examType", examType)
            .setCacheable(true)
            .list());
    exams.addAll(new StudentDAO().getSession().createQuery(
            "select distinct o.exam from ExamOwner o, StudentClassEnrollment e "+
            "where e.student.uniqueId=:studentId and o.ownerType=:ownerType and o.ownerId=e.clazz.schedulingSubpart.instrOfferingConfig.uniqueId and o.exam.examType.type=:examType")
            .setLong("studentId", getUniqueId())
            .setInteger("ownerType", ExamOwner.sOwnerTypeConfig)
            .setInteger("examType", examType)
            .setCacheable(true)
            .list());
    exams.addAll(new StudentDAO().getSession().createQuery(
            "select distinct o.exam from ExamOwner o, StudentClassEnrollment e "+
            "where e.student.uniqueId=:studentId and o.ownerType=:ownerType and o.ownerId=e.courseOffering.uniqueId and o.exam.examType.type=:examType")
            .setLong("studentId", getUniqueId())
            .setInteger("ownerType", ExamOwner.sOwnerTypeCourse)
            .setInteger("examType", examType)
            .setCacheable(true)
            .list());
    exams.addAll(new StudentDAO().getSession().createQuery(
            "select distinct o.exam from ExamOwner o, StudentClassEnrollment e "+
            "where e.student.uniqueId=:studentId and o.ownerType=:ownerType and o.ownerId=e.courseOffering.instructionalOffering.uniqueId and o.exam.examType.type=:examType")
            .setLong("studentId", getUniqueId())
            .setInteger("ownerType", ExamOwner.sOwnerTypeOffering)
            .setInteger("examType", examType)
            .setCacheable(true)
            .list());
    return exams;
}
 
Example 12
Source File: BinaryMicrobePcaAnalysis.java    From systemsgenetics with GNU General Public License v3.0 5 votes vote down vote up
private void loadProbeAnnotation() throws IOException {
	
	HashSet<String> platforms = new HashSet<String>();
	platforms.addAll(settings.getDatasetannotations());
	probeAnnotation = new MetaQTL4TraitAnnotation(new File(settings.getProbetranslationfile()), platforms);
	traitList = new MetaQTL4MetaTrait[probeAnnotation.getMetatraits().size()];
	
	int q = 0;
	for (MetaQTL4MetaTrait t : probeAnnotation.getMetatraits()) {
		traitList[q] = t;
		traitMap.put(t, q);
		q++;
	}
	
}
 
Example 13
Source File: Workspace.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
void updateUnvailableItemsInCellLayout(CellLayout parent, ArrayList<String> packages) {
    final HashSet<String> packageNames = new HashSet<String>();
    packageNames.addAll(packages);

    ViewGroup layout = parent.getShortcutsAndWidgets();
    int childCount = layout.getChildCount();
    for (int i = 0; i < childCount; ++i) {
        View view = layout.getChildAt(i);
        if (view instanceof BubbleTextView) {
            ItemInfo info = (ItemInfo) view.getTag();
            if (info instanceof ShortcutInfo) {
                Intent intent = info.getIntent();
                ComponentName cn = intent != null ? intent.getComponent() : null;
                if (cn != null && packageNames.contains(cn.getPackageName())) {
                    ShortcutInfo shortcut = (ShortcutInfo) info;
                    if (shortcut.isDisabled == 0) {
                        shortcut.isDisabled = 1;
                        ((BubbleTextView) view)
                                .applyFromShortcutInfo(shortcut, mIconCache, true);
                    }
                }
            }
        } else if (view instanceof FolderIcon) {
            final Folder folder = ((FolderIcon)view).getFolder();
            final FolderPagedView folderPagedView = (FolderPagedView)folder.getContent();
            final int N = folderPagedView.getItemCount();
            for (int page = 0; page < N; page++) {
                final CellLayout cellLayout = folderPagedView.getPageAt(page);
                if (cellLayout != null) {
                    updateUnvailableItemsInCellLayout(cellLayout, packages);
                }
            }
            folder.invalidate();
        }
    }
}
 
Example 14
Source File: PDGroups.java    From openprodoc with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Init retrieving of what groups the UserName is member
 * @param UserName Name of user to check
 * @return a HashSet of names of Groups the user is member
 * @throws PDException in any error
 */
public HashSet FullUserMemberShip(String UserName) throws PDException
{
HashSet Result=new HashSet();
HashSet Partial=DirectUserMemberShip(UserName);
Result.addAll(Partial);
for (Iterator it = Partial.iterator(); it.hasNext();)
    {
    String GrpName = (String)it.next();
    PDGroups G=new PDGroups(getDrv());
    Result.addAll(G.FullGroupMemberShip(GrpName));
    }
return(Result);
}
 
Example 15
Source File: TaskGroup.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Run 'beforeGroupInvoke' method of the tasks in this group. The tasks can use beforeGroupInvoke()
 * method to add additional dependencies or dependents.
 *
 * @param skip the keys of the tasks that are previously processed hence they must be skipped
 * @return the keys of all the tasks those are processed (including previously processed items in skip param)
 */
private Set<String> runBeforeGroupInvoke(final Set<String> skip) {
    HashSet<String> processedEntryKeys = new HashSet<>();
    if (skip != null) {
        processedEntryKeys.addAll(skip);
    }
    List<TaskGroupEntry<TaskItem>> entries = this.entriesSnapshot();
    boolean hasMoreToProcess;
    // Invokes 'beforeGroupInvoke' on a subset of non-processed tasks in the group.
    // Initially processing is pending on all task items.
    do {
        hasMoreToProcess = false;
        for (TaskGroupEntry<TaskItem> entry : entries) {
            if (!processedEntryKeys.contains(entry.key())) {
                entry.data().beforeGroupInvoke();
                processedEntryKeys.add(entry.key());
            }
        }
        int prevSize = entries.size();
        entries = this.entriesSnapshot();
        if (entries.size() > prevSize) {
            // If new task dependencies/dependents added in 'beforeGroupInvoke' then
            // set the flag which indicates another pass is required to 'prepare' new
            // task items
            hasMoreToProcess = true;
        }
    } while (hasMoreToProcess);  // Run another pass if new dependencies/dependents were added in this pass
    super.prepareForEnumeration();
    return processedEntryKeys;
}
 
Example 16
Source File: ServerSocketChannelImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<>();
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    if (Net.isReusePortAvailable()) {
        set.add(StandardSocketOptions.SO_REUSEPORT);
    }
    set.addAll(ExtendedSocketOptions.serverSocketOptions());
    return Collections.unmodifiableSet(set);
}
 
Example 17
Source File: ClassDef.java    From Concurnas with MIT License 4 votes vote down vote up
@Override
public HashSet<ClassDef> getTraitsIncTrans() {
	HashSet<ClassDef> ret = getTraits();
	ret.addAll(this.getSuperclass().getTraitsIncTrans());
	return ret;
}
 
Example 18
Source File: Props.java    From liteflow with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a set of all keys, including the parents
 */
public Set<String> getKeySet() {
  final HashSet<String> keySet = new HashSet<>();
  keySet.addAll(localKeySet());
  return keySet;
}
 
Example 19
Source File: GroupingAJAXController.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Stores lesson grouping as a course grouping.
    */
   @RequestMapping(path = "/saveAsCourseGrouping", method = RequestMethod.POST)
   @ResponseBody
   public String saveAsCourseGrouping(HttpServletRequest request, HttpServletResponse response) throws IOException {

HttpSession ss = SessionManager.getSession();
Integer userId = ((UserDTO) ss.getAttribute(AttributeNames.USER)).getUserID();
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
String newGroupingName = request.getParameter("name");

// check if user is allowed to view and edit groupings
if (!securityService.hasOrgRole(organisationId, userId,
	new String[] { Role.GROUP_MANAGER, Role.MONITOR, Role.AUTHOR },
	"view organisation groupings", false)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a participant in the organisation");
    return null;
}

Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID);
Activity activity = monitoringService.getActivityById(activityID);
Grouping grouping = activity.isChosenBranchingActivity() ? activity.getGrouping()
	: ((GroupingActivity) activity).getCreateGrouping();

// iterate over groups
List<OrganisationGroup> orgGroups = new LinkedList<>();
for (Group group : grouping.getGroups()) {
    OrganisationGroup orgGroup = new OrganisationGroup();
    //groupId and GroupingId will be set during  userManagementService.saveOrganisationGrouping() call
    orgGroup.setName(group.getGroupName());
    HashSet<User> users = new HashSet<>();
    users.addAll(group.getUsers());
    orgGroup.setUsers(users);

    orgGroups.add(orgGroup);
}

OrganisationGrouping orgGrouping = new OrganisationGrouping();
orgGrouping.setOrganisationId(organisationId);
orgGrouping.setName(newGroupingName);

userManagementService.saveOrganisationGrouping(orgGrouping, orgGroups);

response.setContentType("application/json;charset=utf-8");
ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
responseJSON.put("result", true);
return responseJSON.toString();
   }
 
Example 20
Source File: QTIEditHelperEBL.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Retrieves all referenced media by thisItem if filterOut is false, or all referenced media by other items if filterOut is true.
 * <p>
 * Iterates over all sections, items, etc. </br> -> if filterOut is true gets all references except those for thisItem. -> if filterOut is false gets all references
 * for thisItem.
 * 
 * @param qtiDocument
 * @param thisItem
 * @param filterOut
 * @return Returns empty set if no reference found.
 */
private static Set<String> getMediaReferences(final QTIDocument qtiDocument, final Item thisItem, final boolean filterOut) {
    final HashSet<String> returnSet = new HashSet<String>();
    // sections
    final List sectionList = qtiDocument.getAssessment().getSections();
    final Iterator sectionIterator = sectionList.iterator();
    while (sectionIterator.hasNext()) {
        // section
        final Section section = (Section) sectionIterator.next();
        final List itemList = section.getItems();
        final Iterator listIterator = itemList.iterator();
        while (listIterator.hasNext()) {
            // item
            final Item item = (Item) listIterator.next();
            if ((filterOut && thisItem.getIdent().equals(item.getIdent())) || (!filterOut && !thisItem.getIdent().equals(item.getIdent()))) {
                continue;
            }
            // question
            final Material material = item.getQuestion().getQuestion();
            if (material != null) {
                final String htmlContent = material.renderAsHtmlForEditor();
                // parse filenames
                returnSet.addAll(getMediaFileNames(htmlContent));
            }
            // responses
            final List responseList = item.getQuestion().getResponses();
            final Iterator responseIterator = responseList.iterator();
            while (responseIterator.hasNext()) {
                final Response response = (Response) responseIterator.next();
                final Material responseMat = response.getContent();
                // parse filenames
                if (responseMat != null) {
                    returnSet.addAll(getMediaFileNames(responseMat.renderAsHtmlForEditor()));
                }
                // response-level feedback
                final Material responseFeedbackMat = QTIEditHelperEBL.getFeedbackOlatRespMaterial(item, response.getIdent());
                if (responseFeedbackMat != null) {
                    returnSet.addAll(getMediaFileNames(responseFeedbackMat.renderAsHtmlForEditor()));
                }
            }
            // feedback
            final Material masteryMat = QTIEditHelperEBL.getFeedbackMasteryMaterial(item);
            if (masteryMat != null) {
                returnSet.addAll(getMediaFileNames(masteryMat.renderAsHtmlForEditor()));
            }
            final Material failureMat = QTIEditHelperEBL.getFeedbackFailMaterial(item);
            if (failureMat != null) {
                returnSet.addAll(getMediaFileNames(failureMat.renderAsHtmlForEditor()));
            }
        }
    }
    return returnSet;
}