Example usage for java.util Set clear

List of usage examples for java.util Set clear

Introduction

In this page you can find the example usage for java.util Set clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this set (optional operation).

Usage

From source file:org.apache.carbondata.datamap.bloom.BloomCoarseGrainDataMapFactory.java

/**
 * returns all shard directories of bloom index files for query
 * if bloom index files are merged we should get only one shard path
 *//*from  w w w.  ja  v  a 2s . c o  m*/
public static Set<String> getAllShardPaths(String tablePath, String segmentId, String dataMapName) {
    String dataMapStorePath = CarbonTablePath.getDataMapStorePath(tablePath, segmentId, dataMapName);
    CarbonFile[] carbonFiles = FileFactory.getCarbonFile(dataMapStorePath).listFiles();
    Set<String> shardPaths = new HashSet<>();
    boolean mergeShardInprogress = false;
    CarbonFile mergeShardFile = null;
    for (CarbonFile carbonFile : carbonFiles) {
        if (carbonFile.getName().equals(BloomIndexFileStore.MERGE_BLOOM_INDEX_SHARD_NAME)) {
            mergeShardFile = carbonFile;
        } else if (carbonFile.getName().equals(BloomIndexFileStore.MERGE_INPROGRESS_FILE)) {
            mergeShardInprogress = true;
        } else if (carbonFile.isDirectory()) {
            shardPaths.add(FileFactory.getPath(carbonFile.getAbsolutePath()).toString());
        }
    }
    if (mergeShardFile != null && !mergeShardInprogress) {
        // should only get one shard path if mergeShard is generated successfully
        shardPaths.clear();
        shardPaths.add(FileFactory.getPath(mergeShardFile.getAbsolutePath()).toString());
    }
    return shardPaths;
}

From source file:edu.kit.dama.mdm.dataorganization.impl.staging.DataOrganizationNodeImpl.java

@Override
final public void setAttributes(Set<? extends IAttribute> attributes) {
    Set<IAttribute> myAttributes = getAttributes();
    myAttributes.clear();
    for (IAttribute attr : attributes) {
        myAttributes.add(attr);/* w  w w. j  a v  a2  s.c om*/
    }
}

From source file:com.smhdemo.common.report.service.ChartService.java

@Override
public Long updChart(Chart vo) {
    Assert.notNull(vo);//  w  w  w .  jav  a  2s  . c om
    Assert.hasLength(vo.getChartSql());

    Chart entity = chartDao.get(vo.getId());

    entity.setName(vo.getName());
    entity.setBaseDS(vo.getBaseDS());
    entity.setType(vo.getType());
    entity.setShowTooltips(vo.getShowTooltips());
    entity.setChartTitle(vo.getChartTitle());
    entity.setFontName(vo.getFontName());
    entity.setFontSize(vo.getFontSize());
    entity.setFontStyle(vo.getFontStyle());
    entity.setHorizAxisLabel(vo.getHorizAxisLabel());
    entity.setVertAxisLabel(vo.getVertAxisLabel());
    entity.setDataFontName(vo.getDataFontName());
    entity.setDataFontSize(vo.getDataFontSize());
    entity.setDataFontStyle(vo.getDataFontStyle());
    entity.setAxisFontName(vo.getAxisFontName());
    entity.setAxisFontSize(vo.getAxisFontSize());
    entity.setAxisFontStyle(vo.getAxisFontStyle());
    entity.setAxisTickFontName(vo.getAxisTickFontName());
    entity.setAxisTickFontSize(vo.getAxisTickFontSize());
    entity.setAxisTickFontStyle(vo.getAxisTickFontStyle());
    entity.setTickLabelRotate(vo.getTickLabelRotate());
    entity.setShowLegend(vo.getShowLegend());
    entity.setLegendPosition(vo.getLegendPosition());
    entity.setLegendFontName(vo.getLegendFontName());
    entity.setLegendFontSize(vo.getLegendFontSize());
    entity.setLegendFontStyle(vo.getLegendFontStyle());
    entity.setChartHeight(vo.getChartHeight());
    entity.setChartWidth(vo.getChartWidth());
    entity.setBgColorB(vo.getBgColorB());
    entity.setBgColorG(vo.getBgColorG());
    entity.setBgColorR(vo.getBgColorR());
    entity.setRemark(vo.getRemark());
    entity.setUpdateDate(new Date(Calendar.getInstance().getTime().getTime()));

    if (!entity.getChartSql().equals(vo.getChartSql())) {
        entity.setChartSql(vo.getChartSql());
        Set<Parameter> oldParameters = entity.getParameters();
        oldParameters.clear();
        Set<Parameter> newParameters = ChartAnalysisUtil.analysisSql(vo.getChartSql());
        for (Parameter newParameter : newParameters) {
            oldParameters.add(newParameter);
        }
        entity.setParameters(oldParameters);
    }
    chartDao.merge(entity);
    return vo.getId();
}

From source file:com.edgenius.wiki.integration.webservice.impl.WsUserServiceImpl.java

public Integer updateUser(WsUser wsUser) {
    if (StringUtils.isBlank(wsUser.getUsername())) {
        throw new WebServiceException("Username can't be blank when update user.");
    }//from ww  w . j av a  2s.c  o m
    User user = userReadingService.getUserByName(wsUser.getUsername().trim());
    if (user == null) {
        throw new WebServiceException("User doesn't exist by username [" + wsUser.getUsername() + "]");
    }

    Set<Role> roles = user.getRoles();
    RoleList wsRoles = wsUser.getRoles();
    roles.clear();
    if (wsRoles != null) {
        for (String name : wsRoles.getRolename()) {
            Role role = roleService.getRoleByName(name);
            if (role == null)
                throw new WebServiceException("Role [" + name + "] does not exist.");

            roles.add(role);
        }
    } else {
        //default role - so far only RegisterUser role
        roles.addAll(roleService.getDefaultRole());
    }

    wsUser.copyTo(user);
    if (Global.EncryptPassword) {
        user.setPassword(CodecUtil.encodePassword(wsUser.getPassword(), Global.PasswordEncodingAlgorithm));
    }

    user = userService.updateUserWithIndex(user);

    return user.getUid();
}

From source file:com.smhdemo.common.report.service.TextService.java

@Override
public Long updText(Text vo) throws BaseException {
    Text entity = textDao.get(vo.getId());

    entity.setBaseDS(vo.getBaseDS());// w ww .  j  a  va2s.  c o  m
    entity.setName(vo.getName());
    entity.setHidden(vo.getHidden());
    entity.setRemark(vo.getRemark());
    entity.setUpdateDate(new Date(Calendar.getInstance().getTime().getTime()));
    byte[] reportFile = vo.getTextEntity();
    if (reportFile != null && reportFile.length > 0) {
        entity.setTextEntity(vo.getTextEntity());

        InputStream in = new ByteArrayInputStream(reportFile);
        TextDesignUtil rd = new TextDesignUtil(in);

        List<JRParameter> paramList = rd.getParameters();
        Set<Parameter> oldParameters = entity.getParameters();
        oldParameters.clear();
        for (JRParameter param : paramList) {
            Parameter parameter = getParameterValue(param);
            oldParameters.add(parameter);
        }
        entity.setParameters(oldParameters);
    }
    textDao.merge(entity);
    return entity.getId();

}

From source file:edu.uci.ics.asterix.optimizer.rules.PushGroupByThroughProduct.java

private PushTestResult canPushThrough(GroupByOperator gby, ILogicalOperator branch,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> toPush,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> notToPush) throws AlgebricksException {
    Collection<LogicalVariable> fromBranch = new HashSet<LogicalVariable>();
    VariableUtilities.getLiveVariables(branch, fromBranch);
    Collection<LogicalVariable> usedInGbyExprList = new ArrayList<LogicalVariable>();
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : gby.getGroupByList()) {
        p.second.getValue().getUsedVariables(usedInGbyExprList);
    }/*from w w  w  .  j a v  a2s.c  om*/

    if (!fromBranch.containsAll(usedInGbyExprList)) {
        return PushTestResult.FALSE;
    }
    Set<LogicalVariable> free = new HashSet<LogicalVariable>();
    for (ILogicalPlan p : gby.getNestedPlans()) {
        for (Mutable<ILogicalOperator> r : p.getRoots()) {
            OperatorPropertiesUtil.getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) r.getValue(), free);
        }
    }
    if (!fromBranch.containsAll(free)) {
        return PushTestResult.FALSE;
    }

    Set<LogicalVariable> decorVarRhs = new HashSet<LogicalVariable>();
    decorVarRhs.clear();
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : gby.getDecorList()) {
        ILogicalExpression expr = p.second.getValue();
        if (expr.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
            return PushTestResult.FALSE;
        }
        VariableReferenceExpression varRef = (VariableReferenceExpression) expr;
        LogicalVariable v = varRef.getVariableReference();
        if (decorVarRhs.contains(v)) {
            return PushTestResult.REPEATED_DECORS;
        }
        decorVarRhs.add(v);

        if (fromBranch.contains(v)) {
            toPush.add(p);
        } else {
            notToPush.add(p);
        }
    }
    return PushTestResult.TRUE;
}

From source file:org.apache.geode.internal.process.signal.AbstractSignalNotificationHandler.java

boolean unregisterListeners(final Signal signal) {
    assertNotNull(signal, "The signal from which to unregister all listeners cannot be null!");

    Set<SignalListener> listeners = signalListeners.get(signal);

    synchronized (listeners) {
        listeners.clear();
        return listeners.isEmpty();
    }//from   w  w w  . j  a va  2  s  . c o  m
}

From source file:com.redhat.rhn.frontend.action.token.configuration.RankChannelsAction.java

/**
 * Updates the set and then applies changes to the server
 * @param mapping struts ActionMapping//from   w ww  .  j  a  va  2  s.co  m
 * @param formIn struts ActionForm
 * @param request HttpServletRequest
 * @param response HttpServletResponse
 * @return An action forward to the success page
 */
public ActionForward update(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) {
    RequestContext context = new RequestContext(request);
    // if its not javascript enabled, can't do much report error
    if (!context.isJavaScriptEnabled()) {
        return handleNoScript(mapping, formIn, request, response);
    }

    User user = context.getCurrentUser();
    DynaActionForm form = (DynaActionForm) formIn;
    ActivationKey key = context.lookupAndBindActivationKey();

    for (Long id : getChannelIds(form)) {
        ConfigChannel channel = ConfigurationFactory.lookupConfigChannelById(id);
        ConfigChannelListProcessor proc = new ConfigChannelListProcessor();
        proc.add(key.getConfigChannelsFor(user), channel);
    }

    Set<String> set = getSet(context);
    set.clear();
    String[] params = { key.getNote() };
    getStrutsDelegate().saveMessage("sdc.config.rank.jsp.success", params, request);
    SessionSetHelper.obliterate(request, request.getParameter(SubscribeChannelsAction.DECL));
    return getStrutsDelegate().forwardParam(mapping.findForward("success"), RequestContext.TOKEN_ID,
            key.getId().toString());
}

From source file:org.opendatakit.security.server.SecurityServiceUtil.java

/**
 * Ensures that a (single) registered user record exists for the superUser, adds that user to the
 * list of site administrators, establishes that user as the sole user with permanent access to
 * the permissions management tab, and, if the user is new, it sets a flag to force the user to
 * visit the permissions tab upon first access to the site (this is done inside assertSuperUser).
 *
 * @param cc/* www .  j  a  v a  2  s. c  o  m*/
 * @throws ODKDatastoreException
 */
public static final synchronized void superUserBootstrap(CallingContext cc) throws ODKDatastoreException {
    // assert that the superuser exists...

    List<RegisteredUsersTable> suList = RegisteredUsersTable.assertSuperUsers(cc);

    Set<String> uriUsers;

    // add the superuser to the list of site administrators
    uriUsers = UserGrantedAuthority.getUriUsers(siteAuth, cc.getDatastore(), cc.getCurrentUser());
    for (RegisteredUsersTable su : suList) {
        uriUsers.add(su.getUri());
    }
    UserGrantedAuthority.assertGrantedAuthorityMembers(siteAuth, uriUsers, cc);

    // assert that the superuser is the only one with permanent access
    // administration rights...
    uriUsers.clear();
    for (RegisteredUsersTable su : suList) {
        uriUsers.add(su.getUri());
    }
    UserGrantedAuthority.assertGrantedAuthorityMembers(
            new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_SITE_ACCESS_ADMIN.name()), uriUsers, cc);
}

From source file:org.apache.axis2.client.WSDLBasedPolicyProcessor.java

public void configureOperationPolices(AxisOperation op) throws AxisFault {
    Policy policy = op.getEffectivePolicy();
    if (policy != null) {
        policy = (Policy) policy.normalize(false);

        Set<String> namespaceSet = new HashSet<String>();
        for (List<PolicyComponent> assertionList : policy.getAlternatives()) {
            namespaceSet.clear();

            //First we compute the set of distinct namespaces of assertions
            //of this particular policy alternative.
            for (PolicyComponent assertion : assertionList) {
                if (assertion instanceof Assertion) {
                    QName name = ((Assertion) assertion).getName();
                    String namespaceURI = name.getNamespaceURI();
                    namespaceSet.add(namespaceURI);
                }//from   w w w.j  av  a 2s  .  c o m
            }

            //Compute all modules involved in process assertions that
            //belong to any of the namespaces we found before.
            for (String namespace : namespaceSet) {
                List<AxisModule> modulesToEngage = ns2modules.get(namespace);
                if (modulesToEngage == null) {
                    log.error("Cannot find any modules to process " + namespace + "type assertions");
                    continue;
                } else {
                    engageModulesToAxisDescription(modulesToEngage, op);
                }
            }

            //We only pick the first policy alternative. Other policy
            //alternatives are ignored.  TODO:  maybe we should complain
            //if there are other alternatives given?
            break;
        }
    }
}