Example usage for java.util List removeAll

List of usage examples for java.util List removeAll

Introduction

In this page you can find the example usage for java.util List removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:net.firejack.platform.core.cache.CacheProcessor.java

@Override
public void removePermissions(List<UserPermission> permissionsToDelete) {
    if (ConfigContainer.isAppInstalled() && permissionsToDelete != null) {
        CacheManager cacheManager = CacheManager.getInstance();
        Map<Long, List<UserPermission>> rolePermissions = cacheManager.getAllRolePermissions();
        if (rolePermissions != null) {
            List<Long> updatedRoles = new ArrayList<Long>();
            for (Map.Entry<Long, List<UserPermission>> entry : rolePermissions.entrySet()) {
                List<UserPermission> permissions = entry.getValue();
                if (permissions != null && permissions.removeAll(permissionsToDelete)) {
                    updatedRoles.add(entry.getKey());
                }// w ww . j  a  va  2  s .c  o  m
            }
            //update id filters
            if (!updatedRoles.isEmpty()) {
                for (Map.Entry<Long, List<Long>> entry : cacheManager.getUserRoles().entrySet()) {
                    if (CollectionUtils.containsAny(entry.getValue(), updatedRoles)) {
                        updateIdFiltersOnRolesChange(entry.getKey(), entry.getValue());
                    }
                }
            }
            UserSessionManager.getInstance().refreshRolePermissions();
        }
    }
}

From source file:gov.nasa.arc.spife.core.plan.advisor.resources.ProfileConstraintPlanAdvisor.java

private void ensureDerivedProfileConstraints(ProfileMember planProfileMember) {
    for (ENumericResourceDef def : AD.getDefinitions(ENumericResourceDef.class)) {
        if (shouldHandleDef(def)) {
            ensureProfileConstraint(def.getName(), def, planProfileMember);
        }/*from  w w  w. j a v a2 s  .  c o  m*/
    }
    for (ObjectDef def : AD.getDefinitions(ObjectDef.class)) {
        for (EStructuralFeature feature : def.getEStructuralFeatures()) {
            if (feature instanceof ENumericResourceDef && shouldHandleDef((ENumericResourceDef) feature)) {
                for (EObject object : EMFUtils.getReachableObjectsOfType(plan, def)) {
                    String profileKey = ProfileUtil.getStructuralFeatureProfileId(object, feature);
                    ensureProfileConstraint(profileKey, (ENumericResourceDef) feature, planProfileMember);
                }
            }
        }
    }
    // Clean up constraints from the plan that are no longer derived from the AD
    List<ProfileConstraint> constraints = planProfileMember.getConstraints();
    List<ProfileConstraint> removedConstraints = new ArrayList<ProfileConstraint>();
    for (ProfileConstraint constraint : constraints) {
        if (!(constraint instanceof ProfileEnvelopeConstraint)) {
            continue;
        }
        ProfileEnvelopeConstraint existingConstraint = (ProfileEnvelopeConstraint) constraint;
        if (!existingConstraint.isFromAD()) {
            continue;
        }
        boolean found = false;
        for (ProfileEnvelopeConstraint adConstraint : constraintsFromAD) {
            if (ProfileEnvelopeConstraintImpl.equals(existingConstraint, adConstraint)) {
                found = true;
                break;
            }
        }
        if (!found) {
            removedConstraints.add(existingConstraint);
        }
    }
    constraints.removeAll(removedConstraints);
    for (ProfileConstraint constraint : constraints) {
        if (constraint instanceof ProfileEnvelopeConstraint) {
            constraint.eAdapters().add(envelopeAdapter);
        }
    }
}

From source file:gov.nih.nci.cabig.caaers.domain.AdverseEvent.java

public void removeOtherOutcomes(List<OutcomeType> outcomeTypesToRetain) {
    List<OutcomeType> typesToRemove = OutcomeType.outcomeTypesAsList();
    typesToRemove.removeAll(outcomeTypesToRetain);

    for (OutcomeType t : typesToRemove) {
        Outcome o = getOutcomeOfType(t);
        if (o != null)
            getOutcomes().remove(o);/*from ww w . ja  va  2  s.c om*/
    }
}

From source file:de.unihannover.l3s.mws.bean.CompareSearches.java

public String searcAll(int nuovo) {

    // System.out.println("TYPE: ALL nuovo: "+nuovo);

    String accountKey = "BmbX+6Sy9/VEcS5oOjurccO5MQpKr2ewvLQ2vRHBKXQ";
    accountKey = "TTtbr2RdFtN8bvzLZG9SIEgkDa7ecUDNrAkdwEy86UI";
    TextManager tmgr = new TextManager();
    tmgr.setCotextrange(this.user.getUtente().getCotextrange());
    searchterms.removeAll(Collections.singleton(""));
    String q = "";
    for (String t : this.searchterms) {
        q += "\"" + t + "\" ";
    }//w w  w .j av a 2s.  c o  m

    if (nuovo == 1) {
        siteAvailablelist1.clear();
        siteAvailablelist2.clear();
        siteAvailablelist3.clear();
        siteSelectedlist1.clear();
        siteSelectedlist2.clear();
        siteSelectedlist3.clear();
    }

    if (!(this.user.getUtente().hasAllLoc()))
        for (Generalsettings gs : this.loclist)
            if (this.loclistsel.compareTo(gs.getId() + "") == 0)
                q += " loc:" + locMap.get(gs.getValue());

    List<String> exclude = new ArrayList<String>(siteAvailablelist1);
    exclude.removeAll(siteSelectedlist1);
    exclude.addAll(excludeWeb);
    exclude.addAll(excludeImg);
    exclude.addAll(excludeVid);
    for (String s : exclude)
        q += " -site:" + s;

    if (!(this.user.getUtente().hasAllLang()))
        // for (String s : this.langlistsel)
        for (Generalsettings gs : this.langlist)
            if (this.langlistsel.compareTo(gs.getId() + "") == 0)
                q += " language:" + gs.getValue() + " ";

    String qweb = "    ";
    for (SiteSetItem ssi : this.user.getUtente().getSitesetitem()) {
        qweb += " site:" + ssi.getUrl() + " OR ";
    }
    qweb = qweb.substring(0, qweb.length() - 4);
    if (qweb.trim().length() != 0)
        qweb = " (" + qweb + ") ";

    q = q + " " + qweb; // ADDED TO HAVE RESTRICTION ALSO ON VIDEOS AND IMAGES 
    qweb = "";
    System.out.println(q + " " + qweb);

    // if (this.searchtype.compareTo("Web")==0){
    AzureSearchWebQuery aq = new AzureSearchWebQuery();
    aq.setAppid(accountKey);
    aq.setQuery(q + " " + qweb);

    // aq.setQuery(q);
    // System.out.println(q);
    List<AzureSearchWebResult> arsall = new ArrayList<AzureSearchWebResult>();
    int conta = -1;
    int contaquery = 0;
    for (int i = 1; i <= 2 && conta != 0; i++) {
        contaquery++;
        aq.setPerPage(50);
        aq.setPage(i);
        aq.doQuery();

        AzureSearchResultSet<AzureSearchWebResult> ars = aq.getQueryResult();
        // System.out.println("TOTAL:"+ars.getWebTotal());
        if (ars.getAsrs().size() < 50)
            conta = 0;
        for (AzureSearchWebResult anr : ars) {
            arsall.add(anr);
        }
    }

    searchResultWeb = new ArrayList<SearchResult>();
    // WIKIMEDIA: http://en.wikipedia.org/w/api.php?action=query&titles=Berlin&prop=revisions&rvprop=timestamp&rvdir=newer&format=xml
    // LASTFM: http://ws.audioscrobbler.com/2.0/?method=artist.getshouts&artist=Berlin&api_key=9b6009eca365ded3a03c2b9673d54eb9&page=3
    List<String> ripetiz = new ArrayList<String>();
    for (AzureSearchWebResult anr : arsall) {

        SearchWebResult r = new SearchWebResult();
        r.setTitle(anr.getTitle());
        // r.setDescription(tmgr.SingleTextToCheck(this.searchterms.get(0), anr.getDescription(), 0));

        r.setDescription(tmgr.MultipleTextToCheck(this.searchterms, anr.getDescription(), 0));
        teasers.add(anr.getDescription());
        r.setUrl(anr.getUrl());
        if (!ripetiz.contains(r.getUrl())) {
            ripetiz.add(r.getUrl());
            searchResultWeb.add(r);
        }
    }
    searchResult1 = new ArrayList<SearchResult>(searchResultWeb);
    // }
    // if (this.searchtype.compareTo("Video")==0){
    AzureSearchVideoQuery aqv = new AzureSearchVideoQuery();
    aqv.setAppid(accountKey);
    aqv.setQuery(q);
    List<AzureSearchVideoResult> arsallv = new ArrayList<AzureSearchVideoResult>();
    conta = -1;
    for (int i = 1; i <= 2 && conta != 0; i++) {
        contaquery++;
        aqv.setPerPage(50);
        aqv.setPage(i);
        aqv.doQuery();
        AzureSearchResultSet<AzureSearchVideoResult> ars = aqv.getQueryResult();

        if (ars.getAsrs().size() < 50)
            conta = 0;
        for (AzureSearchVideoResult anr : ars) {
            // System.out.println("Page : "+i+" size ars: "+anr.getMediaUrl());
            arsallv.add(anr);
        }
    }
    // searchResult2=new ArrayList<SearchResult>();
    searchResultVideo = new ArrayList<SearchResult>();
    ripetiz = new ArrayList<String>();
    for (AzureSearchVideoResult anr : arsallv) {
        SearchVideoResult r = new SearchVideoResult();
        r.setTitle(anr.getTitle());
        // r.setHeight(anr.getThumbnail().getHeight());
        // r.setWidth(anr.getThumbnail().getWidth());
        r.setRuntime("" + anr.getRunTime());
        r.setThumbnail(anr.getThumbnail());
        r.setUrl(anr.getMediaUrl());
        // System.out.println(r.getUrl());
        if (!ripetiz.contains(r.getUrl())) {
            ripetiz.add(r.getUrl());
            searchResultVideo.add(r);
        }
    }
    searchResult2 = new ArrayList<SearchResult>(searchResultVideo);
    // }
    // if (this.searchtype.compareTo("Image")==0){
    AzureSearchImageQuery aqi = new AzureSearchImageQuery();
    aqi.setAppid(accountKey);
    aqi.setQuery(q);
    List<AzureSearchImageResult> arsalli = new ArrayList<AzureSearchImageResult>();
    conta = -1;
    for (int i = 1; i <= 2 && conta != 0; i++) {
        contaquery++;
        aqi.setPage(i);
        aqi.setPerPage(50);
        aqi.doQuery();
        AzureSearchResultSet<AzureSearchImageResult> ars = aqi.getQueryResult();
        if (ars.getAsrs().size() < 50)
            conta = 0;

        for (AzureSearchImageResult anr : ars) {
            arsalli.add(anr);
        }
    }
    searchResultImg = new ArrayList<SearchResult>();
    ripetiz = new ArrayList<String>();
    for (AzureSearchImageResult anr : arsalli) {
        SearchImageResult r = new SearchImageResult();
        r.setTitle(anr.getTitle());
        r.setHeight(anr.getHeight());
        r.setWidth(anr.getWidth());
        r.setUrl(anr.getMediaUrl());
        if (!ripetiz.contains(r.getUrl())) {
            ripetiz.add(r.getUrl());
            searchResultImg.add(r);
        }
    }
    searchResult3 = new ArrayList<SearchResult>(searchResultImg);
    // }

    Track track = new Track();
    track.setDate((new GregorianCalendar()).getTime());
    track.setOperation("search");
    track.setParam1(q + " " + qweb);
    track.setParam2(this.searchtype);
    track.setParam3("" + contaquery);
    track.setUtente(this.user.getUtente());
    TrackDao td = new TrackDao();
    td.addTrack(track);

    if (searchterms.size() == 0)
        searchterms.add("");

    // PIE WEB
    StatsManager sm = new StatsManager();
    List<YData> list = sm.getMatcthTable(sm.getSites(searchResult1, null, null));
    searchDataPie1 = "var data = [ ";
    List<String> datastring = new ArrayList<String>();
    for (YData a : list) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} ");
        if (nuovo == 1) {
            siteAvailablelist1.add(a.getSite());
            siteSelectedlist1.add(a.getSite());
        }
    }
    searchDataPie1 += Joiner.on(",").join(datastring);
    searchDataPie1 += " ]; ";
    searchDataPie1 += " var options = { series: { pie: {show: true, label: {show: false} }  }, grid: { hoverable: true, clickable: true }, legend: {show: false} }; ";
    searchDataPie1 += "$.plot($(\"#chartpie1\"), data, options ); \n";
    // String hover=" $(\"#chartpie1\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black;background-color:\", obj.series.color, \"\\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive1\").html(html.join('')); }); ";
    String hover = " $(\"#chartpie1\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive1\").html(html.join('')); }); ";
    searchDataPie1 += hover;
    searchDataPie1 += " var choiceContainer = $(\"#chartpie1\");";
    searchDataPie1 += " choiceContainer.find(\"input\").click(plotAccordingToChoices);";
    searchDataPie1 += " function plotAccordingToChoices() { ";
    searchDataPie1 += " var key = $(this).attr(\"name\"); ";
    searchDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); ";
    searchDataPie1 += " }";
    searchDataPie1 += "  ";
    // calculateTimeline(searchResult);

    // PIE WEIGHTED WEB

    List<YData> wlist = sm.getMatcthWeightedTable(sm.getSites(searchResult1, null, null));
    searchWeightedDataPie1 = "var weighteddata = [ ";
    datastring = new ArrayList<String>();
    for (YData a : wlist) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} ");
    }
    searchWeightedDataPie1 += Joiner.on(",").join(datastring);
    searchWeightedDataPie1 += " ]; ";
    searchWeightedDataPie1 += "$.plot($(\"#chartweightedpie1\"), weighteddata, options ); \n";
    String hoverW = " $(\"#chartweightedpie1\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive1W\").html(html.join('')); }); ";
    searchWeightedDataPie1 += hoverW;
    searchWeightedDataPie1 += " var choiceContainerW = $(\"#chartweightedpie1\");";
    searchWeightedDataPie1 += " choiceContainerW.find(\"input\").click(plotAccordingToChoicesW);";
    searchWeightedDataPie1 += " function plotAccordingToChoicesW() { ";
    searchWeightedDataPie1 += " var key = $(this).attr(\"name\"); ";
    searchWeightedDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); ";
    searchWeightedDataPie1 += " }";
    searchWeightedDataPie1 += "  ";

    // PIE DOMAIN WEB

    List<YData> Llist = sm.getMatcthTable(sm.getLangSites(searchResult1, null, null));
    searchLangDataPie1 = "var langdata = [ ";
    datastring = new ArrayList<String>();
    for (YData a : Llist) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} ");
        /* if (nuovo==1) {
           siteAvailableDomainlist1.add(a.getSite());
           siteSelectedDomainlist1.add(a.getSite());
        } */
    }
    searchLangDataPie1 += Joiner.on(",").join(datastring);
    searchLangDataPie1 += " ]; ";
    searchLangDataPie1 += "$.plot($(\"#chartlangpie1\"), langdata, options ); \n";
    String hoverL = " $(\"#chartlangpie1\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive1L\").html(html.join('')); }); ";
    searchLangDataPie1 += hoverL;
    String plotclickL = " $(\"#chartlangpie1\").bind(\"plotclick\", function(event, pos, obj){ if (!obj){return;} }); ";
    searchLangDataPie1 += plotclickL;
    searchLangDataPie1 += " var choiceContainerL = $(\"#chartlangpie1\");";
    searchLangDataPie1 += " choiceContainerL.find(\"input\").click(plotAccordingToChoicesL);";
    searchLangDataPie1 += " function plotAccordingToChoicesL() { ";
    searchLangDataPie1 += " var key = $(this).attr(\"name\"); ";
    searchLangDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); ";
    searchLangDataPie1 += " }";
    searchLangDataPie1 += "  ";
    alignSiteDomain();

    // BAR WEB
    searchDataBar1 = " var datawebbar = [ ";
    datastring = new ArrayList<String>();
    int conta2 = 0;
    for (YData a : list) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: [ [" + conta2 + "," + a.getQty() + "] ]} ");
        conta2++;
    }
    searchDataBar1 += Joiner.on(",").join(datastring);
    searchDataBar1 += " ]; ";
    searchDataBar1 += " var baroptions = { series: { bars: {show: true, label: {show: false} }  }, grid: { hoverable: true, clickable: true }, legend: {show: false} }; ";
    searchDataBar1 += "$.plot($(\"#chartbar1\"), datawebbar, baroptions ); \n";
    searchDataBar1 += "  ";

    // PIE VIDEO      
    sm = new StatsManager();
    list = sm.getMatcthTable(sm.getSites(searchResult2, null, null));
    searchDataPie2 = "var data = [ ";
    datastring = new ArrayList<String>();
    for (YData a : list) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} ");
        if (nuovo == 1) {
            siteAvailablelist2.add(a.getSite());
            siteSelectedlist2.add(a.getSite());
        }
    }
    searchDataPie2 += Joiner.on(",").join(datastring);
    searchDataPie2 += " ]; ";
    // searchDataPie2+=" var options = { series: { pie: {show: true, label: {show: false} }  }, grid: { hoverable: true, clickable: true }, legend: {show: false} }; ";
    searchDataPie2 += "$.plot($(\"#chartpie2\"), data, options ); \n";
    // hover=" $(\"#chartpie2\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black;background-color:\", obj.series.color, \"\\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive2\").html(html.join('')); }); ";
    hover = " $(\"#chartpie2\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive2\").html(html.join('')); }); ";
    searchDataPie2 += hover;
    searchDataPie2 += " var choiceContainer2 = $(\"#chartpie2\");";
    searchDataPie2 += " choiceContainer2.find(\"input\").click(plotAccordingToChoices2);";
    searchDataPie2 += " function plotAccordingToChoices2() { ";
    searchDataPie2 += " var key = $(this).attr(\"name\"); ";
    searchDataPie2 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); ";
    searchDataPie2 += " }";
    searchDataPie2 += "  ";

    // PIE IMAGE      
    sm = new StatsManager();
    list = sm.getMatcthTable(sm.getSites(searchResult3, null, null));
    searchDataPie3 = "var data = [ ";
    datastring = new ArrayList<String>();
    for (YData a : list) {
        datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} ");
        if (nuovo == 1) {
            siteAvailablelist3.add(a.getSite());
            siteSelectedlist3.add(a.getSite());
        }
    }
    searchDataPie3 += Joiner.on(",").join(datastring);
    searchDataPie3 += " ]; ";
    // searchDataPie3+=" var options = { series: { pie: {show: true, label: {show: false} }  }, grid: { hoverable: true, clickable: true }, legend: {show: false} }; ";
    searchDataPie3 += "$.plot($(\"#chartpie3\"), data, options ); \n";
    // hover=" $(\"#chartpie3\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black;background-color:\", obj.series.color, \"\\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive3\").html(html.join('')); }); ";
    hover = " $(\"#chartpie3\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive3\").html(html.join('')); }); ";
    searchDataPie3 += hover;
    searchDataPie3 += " var choiceContainer3 = $(\"#chartpie3\");";
    searchDataPie3 += " choiceContainer3.find(\"input\").click(plotAccordingToChoices3);";
    searchDataPie3 += " function plotAccordingToChoices3() { ";
    searchDataPie3 += " var key = $(this).attr(\"name\"); ";
    searchDataPie3 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); ";
    searchDataPie3 += " }";
    searchDataPie3 += "  ";
    // System.out.println("IMAGES: "+searchResult3.size());

    return "basicSearch";

}

From source file:com.inkubator.hrm.web.flow.JobJabatanFormController.java

public void doResetJobJabatanKlasifikasiKerjaForm(RequestContext context) {
    JobJabatanModel jobJabatanModel = (JobJabatanModel) context.getFlowScope().get("jobJabatanModel");
    try {//from   www .j  a va2s  . c o m
        if (jobJabatanModel.getId() == null) {
            List<KlasifikasiKerja> listSourceKlasifikasiKerja = klasifikasiKerjaService.getAllData();
            dualListModelKlasifikasiKerja.setSource(listSourceKlasifikasiKerja);
            dualListModelKlasifikasiKerja.setTarget(new ArrayList<KlasifikasiKerja>());
        } else {

            List<KlasifikasiKerja> listSourceKlasifikasiKerja = klasifikasiKerjaService.getAllData();
            List<KlasifikasiKerjaJabatan> listTargetKlasifikasiKerjaJabatan = klasifikasiKerjaJabatanService
                    .getAllDataByJabatanId(jobJabatanModel.getId());
            List<KlasifikasiKerja> listTargetKlasifikasiKerja = Lambda.extract(
                    listTargetKlasifikasiKerjaJabatan,
                    Lambda.on(KlasifikasiKerjaJabatan.class).getKlasifikasiKerja());
            listSourceKlasifikasiKerja.removeAll(listTargetKlasifikasiKerja);
            dualListModelKlasifikasiKerja = new DualListModel<KlasifikasiKerja>(listSourceKlasifikasiKerja,
                    listTargetKlasifikasiKerja);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    jobJabatanModel.setListKlasifikasiKerja(new ArrayList<KlasifikasiKerja>());
    context.getFlowScope().put("jobJabatanModel", jobJabatanModel);
}

From source file:cz.cas.lib.proarc.webapp.server.rest.DigitalObjectResource.java

/**
 * Removes given children from a parent.
 * <p><b>Requires handler commit!</b>
 * @param parent parent PID//from w w  w. j av  a  2  s. c  o m
 * @param toRemovePidSet PIDs of children to remove
 */
private void deleteMembers(DigitalObjectHandler parent, Set<String> toRemovePidSet)
        throws DigitalObjectException {
    RelationEditor editor = parent.relations();
    List<String> members = editor.getMembers();
    // check that PIDs being removed are members of parent object
    HashSet<String> toRemovePidSetCopy = new HashSet<String>(toRemovePidSet);
    toRemovePidSetCopy.removeAll(members);
    if (!toRemovePidSetCopy.isEmpty()) {
        String msg = String.format("Parent: %s does not contain members: %s", parent.getFedoraObject().getPid(),
                toRemovePidSetCopy.toString());
        throw RestException.plainText(Status.BAD_REQUEST, msg);
    }
    // remove
    if (members.removeAll(toRemovePidSet)) {
        editor.setMembers(members);
        editor.write(editor.getLastModified(), session.asFedoraLog());
    }
}

From source file:com.espertech.esper.core.context.mgr.ContextManagerNested.java

public void contextPartitionNavigate(ContextControllerInstanceHandle existingHandle,
        ContextController originator, ContextControllerState controllerState, int exportedCPOrPathId,
        ContextInternalFilterAddendum filterAddendum, AgentInstanceSelector agentInstanceSelector,
        byte[] payload) {
    ContextManagerNestedInstanceHandle nestedHandle = (ContextManagerNestedInstanceHandle) existingHandle;

    // detect non-leaf
    int nestingLevel = originator.getFactory().getFactoryContext().getNestingLevel(); // starts at 1 for root
    if (nestingLevel < nestedContextFactories.length) {
        nestedHandle.getController().importContextPartitions(controllerState, exportedCPOrPathId,
                filterAddendum, agentInstanceSelector);
        return;/*from w w w.  ja  va  2  s .  c  om*/
    }

    ContextControllerTreeEntry entry = subcontexts.get(originator);
    if (entry == null) {
        return;
    }
    for (Map.Entry<Integer, ContextControllerTreeAgentInstanceList> cpEntry : entry.getAgentInstances()
            .entrySet()) {

        if (cpEntry.getValue().getState() == ContextPartitionState.STOPPED) {
            cpEntry.getValue().setState(ContextPartitionState.STARTED);
            entry.getAgentInstances().clear();
            for (Map.Entry<String, ContextControllerStatementDesc> statement : statements.entrySet()) {
                AgentInstance instance = startStatement(existingHandle.getContextPartitionOrPathId(),
                        statement.getValue(), originator, cpEntry.getValue().getInitPartitionKey(),
                        entry.getInitContextProperties(), false);
                cpEntry.getValue().getAgentInstances().add(instance);
            }
            ContextStatePathKey key = new ContextStatePathKey(nestedContextFactories.length,
                    originator.getPathId(), existingHandle.getSubPathId());
            ContextStatePathValue value = new ContextStatePathValue(
                    existingHandle.getContextPartitionOrPathId(), payload, ContextPartitionState.STARTED);
            originator.getFactory().getStateCache().updateContextPath(contextName, key, value);
        } else {
            List<AgentInstance> removed = new ArrayList<AgentInstance>(2);
            List<AgentInstance> added = new ArrayList<AgentInstance>(2);
            List<AgentInstance> current = cpEntry.getValue().getAgentInstances();

            for (AgentInstance agentInstance : current) {
                if (!agentInstanceSelector.select(agentInstance)) {
                    continue;
                }

                // remove
                StatementAgentInstanceUtil.stopAgentInstance(agentInstance, null, servicesContext, false);
                removed.add(agentInstance);

                // start
                ContextControllerStatementDesc statementDesc = statements
                        .get(agentInstance.getAgentInstanceContext().getStatementId());
                AgentInstance instance = startStatement(cpEntry.getKey(), statementDesc, originator,
                        cpEntry.getValue().getInitPartitionKey(), entry.getInitContextProperties(), false);
                added.add(instance);

                if (controllerState.getPartitionImportCallback() != null) {
                    controllerState.getPartitionImportCallback()
                            .existing(existingHandle.getContextPartitionOrPathId(), exportedCPOrPathId);
                }
            }
            current.removeAll(removed);
            current.addAll(added);
        }
    }
}

From source file:com.microsoft.tfs.core.clients.workitem.internal.rules.FieldPickListSupport.java

public AllowedValuesCollection getAllowedValues() {
    if (allowedValues == null) {
        final List<String> pickList = new ArrayList<String>();

        if (suggested == null && allowed == null) {
            if (log.isDebugEnabled()) {
                log.debug(MessageFormat.format(
                        "{0}: computed non-existing picklist, since suggested and allowed are null", //$NON-NLS-1$
                        debuggingIdentifier));
            }//from   w  ww.  j  a  v a  2 s . c  o  m
        } else {
            if (suggested != null) {
                pickList.addAll(suggested);

                if (log.isDebugEnabled()) {
                    log.debug(MessageFormat.format(
                            "{0}: computing picklist, added {1} suggested values, pick list size = {2}", //$NON-NLS-1$
                            debuggingIdentifier, suggested.size(), pickList.size()));
                }

                if (allowed != null) {
                    pickList.retainAll(allowed);

                    if (log.isDebugEnabled()) {
                        log.debug(MessageFormat.format(
                                "{0}: computing picklist, retained {1} allowed values, pick list size = {2}", //$NON-NLS-1$
                                debuggingIdentifier, allowed.size(), pickList.size()));
                    }
                }
            } else {
                pickList.addAll(allowed);

                if (log.isDebugEnabled()) {
                    log.debug(MessageFormat.format(
                            "{0}: computing picklist, added {1} allowed values, pick list size = {2}", //$NON-NLS-1$
                            debuggingIdentifier, allowed.size(), pickList.size()));
                }
            }

            if (prohibited != null) {
                pickList.removeAll(prohibited);

                if (log.isDebugEnabled()) {
                    log.debug(MessageFormat.format(
                            "{0}: computing picklist, removed {1} prohibited values, pick list size = {2}", //$NON-NLS-1$
                            debuggingIdentifier, prohibited.size(), pickList.size()));
                }
            }

            /*
             * null values are needed for data validation (implicit empty),
             * but don't show them in the picklist
             *
             * TODO: I think this is old code and can be removed. Pretty
             * sure the RuleEngine never adds null to a FieldPickListSupport
             * any more, but need to check this before removing this line.
             */
            pickList.remove(null);

            /*
             * NOTE: we used to check here if the pick list size was empty,
             * and if so set to null. The behavior was that if a pick list
             * is empty, no pick list exists.
             *
             * It seems that the MS OM does not do this - if a pick list is
             * empty a field still has a pick list. Our code was changed to
             * act the same way. The main implication is that on the work
             * item form we show an empty combobox in this case instead of a
             * text box.
             */
        }

        /*
         * Create AllowedValueCollection from list.
         */
        final String[] values = pickList.toArray(new String[pickList.size()]);
        allowedValues = new AllowedValuesCollectionImpl(values, psType);
    }

    return allowedValues;
}

From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.AnnotationPage.java

public AnnotationPage() {
    annotationDetailEditorPanel = new AnnotationDetailEditorPanel("annotationDetailEditorPanel",
            new Model<BratAnnotatorModel>(bratAnnotatorModel)) {
        private static final long serialVersionUID = 2857345299480098279L;

        @Override//from   w ww. j  a  v  a2  s  . c o  m
        protected void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) {
            aTarget.addChildren(getPage(), FeedbackPanel.class);

            try {
                annotator.bratRender(aTarget, getCas(aBModel));
            } catch (UIMAException | ClassNotFoundException | IOException e) {
                LOG.info("Error reading CAS " + e.getMessage());
                error("Error reading CAS " + e.getMessage());
                return;
            }

            annotator.bratRenderHighlight(aTarget, aBModel.getSelection().getAnnotation());

            annotator.onChange(aTarget, aBModel);
            annotator.onAnnotate(aTarget, aBModel, aBModel.getSelection().getBegin(),
                    aBModel.getSelection().getEnd());
            if (!aBModel.getSelection().isAnnotate()) {
                annotator.onDelete(aTarget, aBModel, aBModel.getSelection().getBegin(),
                        aBModel.getSelection().getEnd());
            }
        }
    };

    annotationDetailEditorPanel.setOutputMarkupId(true);
    add(annotationDetailEditorPanel);

    annotator = new BratAnnotator("embedder1", new Model<BratAnnotatorModel>(bratAnnotatorModel),
            annotationDetailEditorPanel) {

        private static final long serialVersionUID = 7279648231521710155L;

        @Override
        public void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel) {
            bratAnnotatorModel = aBratAnnotatorModel;
            aTarget.add(numberOfPages);
        }

        @Override
        public void renderHead(IHeaderResponse aResponse) {
            super.renderHead(aResponse);

            // If the page is reloaded in the browser and a document was already open, we need
            // to render it. We use the "later" commands here to avoid polluting the Javascript
            // header items with document data and because loading times are not that critical
            // on a reload.
            if (getModelObject().getProject() != null) {
                // We want to trigger a late rendering only on a page reload, but not on a
                // Ajax request.
                if (!aResponse.getResponse().getClass().getName().endsWith("AjaxResponse")) {
                    aResponse.render(OnLoadHeaderItem.forScript(bratInitLaterCommand()));
                    aResponse.render(OnLoadHeaderItem.forScript(bratRenderLaterCommand()));
                }
            }
        }
    };

    // This is an Annotation Operation, set model to ANNOTATION mode
    bratAnnotatorModel.setMode(Mode.ANNOTATION);
    add(annotator);

    add(documentNamePanel = (DocumentNamePanel) new DocumentNamePanel("documentNamePanel",
            new Model<BratAnnotatorModel>(bratAnnotatorModel)).setOutputMarkupId(true));

    numberOfPages = new Label("numberOfPages", new Model<String>());
    numberOfPages.setOutputMarkupId(true);
    add(numberOfPages);

    final ModalWindow openDocumentsModal;
    add(openDocumentsModal = new ModalWindow("openDocumentsModal"));
    openDocumentsModal.setOutputMarkupId(true);

    openDocumentsModal.setInitialWidth(500);
    openDocumentsModal.setInitialHeight(300);
    openDocumentsModal.setResizable(true);
    openDocumentsModal.setWidthUnit("px");
    openDocumentsModal.setHeightUnit("px");
    openDocumentsModal.setTitle("Open document");
    openDocumentsModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
        private static final long serialVersionUID = -5423095433535634321L;

        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) {
            closeButtonClicked = true;
            return true;
        }
    });

    add(new AjaxLink<Void>("showOpenDocumentModal") {
        private static final long serialVersionUID = 7496156015186497496L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            closeButtonClicked = false;
            openDocumentsModal.setContent(new OpenModalWindowPanel(openDocumentsModal.getContentId(),
                    bratAnnotatorModel, openDocumentsModal, Mode.ANNOTATION) {

                private static final long serialVersionUID = -3434069761864809703L;

                @Override
                protected void onCancel(AjaxRequestTarget aTarget) {
                    closeButtonClicked = true;
                };
            });
            openDocumentsModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
                private static final long serialVersionUID = -1746088901018629567L;

                @Override
                public void onClose(AjaxRequestTarget target) {
                    // A hack, the dialog opens for the first time, and if no document is
                    // selected window will be "blind down". Something in the brat js causes
                    // this!
                    if (bratAnnotatorModel.getProject() == null || bratAnnotatorModel.getDocument() == null) {
                        setResponsePage(WelcomePage.class);
                    }

                    // Dialog was cancelled rather that a document was selected.
                    if (closeButtonClicked) {
                        return;
                    }

                    loadDocumentAction(target);
                }
            });
            // target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            openDocumentsModal.show(target);
        }
    });

    add(new AnnotationLayersModalPanel("annotationLayersModalPanel",
            new Model<BratAnnotatorModel>(bratAnnotatorModel)) {
        private static final long serialVersionUID = -4657965743173979437L;

        @Override
        protected void onChange(AjaxRequestTarget aTarget) {
            // annotator.reloadContent(aTarget);
            aTarget.appendJavaScript("Wicket.Window.unloadConfirmation = false;" + "window.location.reload()");

        }
    });

    add(new ExportModalPanel("exportModalPanel", new Model<BratAnnotatorModel>(bratAnnotatorModel)));
    // Show the previous document, if exist
    add(new AjaxLink<Void>("showPreviousDocument") {
        private static final long serialVersionUID = 7496156015186497496L;

        /**
         * Get the current beginning sentence address and add on it the size of the display
         * window
         */
        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            // List of all Source Documents in the project
            List<SourceDocument> listOfSourceDocuements = repository
                    .listSourceDocuments(bratAnnotatorModel.getProject());

            String username = SecurityContextHolder.getContext().getAuthentication().getName();
            User user = userRepository.get(username);

            List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>();
            for (SourceDocument sourceDocument : listOfSourceDocuements) {
                if (repository.existsAnnotationDocument(sourceDocument, user)
                        && repository.getAnnotationDocument(sourceDocument, user).getState()
                                .equals(AnnotationDocumentState.IGNORE)) {
                    sourceDocumentsinIgnorState.add(sourceDocument);
                }
            }

            listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState);

            // Index of the current source document in the list
            int currentDocumentIndex = listOfSourceDocuements.indexOf(bratAnnotatorModel.getDocument());

            // If the first the document
            if (currentDocumentIndex == 0) {
                aTarget.appendJavaScript("alert('This is the first document!')");
                return;
            }
            bratAnnotatorModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex - 1).getName());
            bratAnnotatorModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex - 1));

            loadDocumentAction(aTarget);
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click)));

    // Show the next document if exist
    add(new AjaxLink<Void>("showNextDocument") {
        private static final long serialVersionUID = 7496156015186497496L;

        /**
         * Get the current beginning sentence address and add on it the size of the display
         * window
         */
        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            // List of all Source Documents in the project
            List<SourceDocument> listOfSourceDocuements = repository
                    .listSourceDocuments(bratAnnotatorModel.getProject());

            String username = SecurityContextHolder.getContext().getAuthentication().getName();
            User user = userRepository.get(username);

            List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>();
            for (SourceDocument sourceDocument : listOfSourceDocuements) {
                if (repository.existsAnnotationDocument(sourceDocument, user)
                        && repository.getAnnotationDocument(sourceDocument, user).getState()
                                .equals(AnnotationDocumentState.IGNORE)) {
                    sourceDocumentsinIgnorState.add(sourceDocument);
                }
            }

            listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState);

            // Index of the current source document in the list
            int currentDocumentIndex = listOfSourceDocuements.indexOf(bratAnnotatorModel.getDocument());

            // If the first document
            if (currentDocumentIndex == listOfSourceDocuements.size() - 1) {
                aTarget.appendJavaScript("alert('This is the last document!')");
                return;
            }
            bratAnnotatorModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex + 1).getName());
            bratAnnotatorModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex + 1));

            loadDocumentAction(aTarget);
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click)));

    // Show the next page of this document
    add(new AjaxLink<Void>("showNext") {
        private static final long serialVersionUID = 7496156015186497496L;

        /**
         * Get the current beginning sentence address and add on it the size of the display
         * window
         */
        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            try {
                if (bratAnnotatorModel.getDocument() != null) {
                    JCas jCas = getJCas();
                    int nextSentenceAddress = BratAjaxCasUtil.getNextPageFirstSentenceAddress(jCas,
                            bratAnnotatorModel.getSentenceAddress(),
                            bratAnnotatorModel.getPreferences().getWindowSize());
                    if (bratAnnotatorModel.getSentenceAddress() != nextSentenceAddress) {
                        bratAnnotatorModel.setSentenceAddress(nextSentenceAddress);

                        Sentence sentence = selectByAddr(jCas, Sentence.class, nextSentenceAddress);
                        bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                        bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());
                        aTarget.addChildren(getPage(), FeedbackPanel.class);
                        annotator.bratRenderLater(aTarget);
                        gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                                bratAnnotatorModel.getSentenceAddress()) + 1);
                        updateSentenceAddress(jCas, aTarget);
                    }

                    else {
                        aTarget.appendJavaScript("alert('This is last page!')");
                    }
                } else {
                    aTarget.appendJavaScript("alert('Please open a document first!')");
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click)));

    // Show the previous page of this document
    add(new AjaxLink<Void>("showPrevious") {
        private static final long serialVersionUID = 7496156015186497496L;

        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            try {
                if (bratAnnotatorModel.getDocument() != null) {

                    JCas jCas = getJCas();

                    int previousSentenceAddress = BratAjaxCasUtil.getPreviousDisplayWindowSentenceBeginAddress(
                            jCas, bratAnnotatorModel.getSentenceAddress(),
                            bratAnnotatorModel.getPreferences().getWindowSize());
                    if (bratAnnotatorModel.getSentenceAddress() != previousSentenceAddress) {
                        bratAnnotatorModel.setSentenceAddress(previousSentenceAddress);

                        Sentence sentence = selectByAddr(jCas, Sentence.class, previousSentenceAddress);
                        bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                        bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());
                        aTarget.addChildren(getPage(), FeedbackPanel.class);
                        annotator.bratRenderLater(aTarget);
                        gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                                bratAnnotatorModel.getSentenceAddress()) + 1);
                        updateSentenceAddress(jCas, aTarget);
                    } else {
                        aTarget.appendJavaScript("alert('This is First Page!')");
                    }
                } else {
                    aTarget.appendJavaScript("alert('Please open a document first!')");
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click)));

    add(new AjaxLink<Void>("showFirst") {
        private static final long serialVersionUID = 7496156015186497496L;

        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            try {
                if (bratAnnotatorModel.getDocument() != null) {

                    JCas jCas = getJCas();

                    if (bratAnnotatorModel.getFirstSentenceAddress() != bratAnnotatorModel
                            .getSentenceAddress()) {
                        bratAnnotatorModel.setSentenceAddress(bratAnnotatorModel.getFirstSentenceAddress());

                        Sentence sentence = selectByAddr(jCas, Sentence.class,
                                bratAnnotatorModel.getFirstSentenceAddress());
                        bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                        bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());

                        aTarget.addChildren(getPage(), FeedbackPanel.class);
                        annotator.bratRenderLater(aTarget);
                        gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                                bratAnnotatorModel.getSentenceAddress()) + 1);
                        updateSentenceAddress(jCas, aTarget);
                    } else {
                        aTarget.appendJavaScript("alert('This is first page!')");
                    }
                } else {
                    aTarget.appendJavaScript("alert('Please open a document first!')");
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click)));

    add(new AjaxLink<Void>("showLast") {
        private static final long serialVersionUID = 7496156015186497496L;

        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            try {
                if (bratAnnotatorModel.getDocument() != null) {

                    JCas jCas = getJCas();

                    int lastDisplayWindowBeginingSentenceAddress = BratAjaxCasUtil
                            .getLastDisplayWindowFirstSentenceAddress(jCas,
                                    bratAnnotatorModel.getPreferences().getWindowSize());
                    if (lastDisplayWindowBeginingSentenceAddress != bratAnnotatorModel.getSentenceAddress()) {
                        bratAnnotatorModel.setSentenceAddress(lastDisplayWindowBeginingSentenceAddress);

                        Sentence sentence = selectByAddr(jCas, Sentence.class,
                                lastDisplayWindowBeginingSentenceAddress);
                        bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                        bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());
                        aTarget.addChildren(getPage(), FeedbackPanel.class);
                        annotator.bratRenderLater(aTarget);
                        gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                                bratAnnotatorModel.getSentenceAddress()) + 1);
                        updateSentenceAddress(jCas, aTarget);
                    } else {
                        aTarget.appendJavaScript("alert('This is last Page!')");
                    }
                } else {
                    aTarget.appendJavaScript("alert('Please open a document first!')");
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    }.add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click)));

    add(new GuidelineModalPanel("guidelineModalPanel", new Model<BratAnnotatorModel>(bratAnnotatorModel)));

    gotoPageTextField = (NumberTextField<Integer>) new NumberTextField<Integer>("gotoPageText",
            new Model<Integer>(0));
    Form<Void> gotoPageTextFieldForm = new Form<Void>("gotoPageTextFieldForm");
    gotoPageTextFieldForm.add(new AjaxFormSubmitBehavior(gotoPageTextFieldForm, "onsubmit") {
        private static final long serialVersionUID = -4549805321484461545L;

        @Override
        protected void onSubmit(AjaxRequestTarget aTarget) {
            try {
                if (gotoPageAddress == 0) {
                    aTarget.appendJavaScript("alert('The sentence number entered is not valid')");
                    return;
                }
                if (bratAnnotatorModel.getSentenceAddress() != gotoPageAddress) {
                    bratAnnotatorModel.setSentenceAddress(gotoPageAddress);

                    JCas jCas = getJCas();

                    Sentence sentence = selectByAddr(jCas, Sentence.class, gotoPageAddress);
                    bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                    bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());

                    aTarget.addChildren(getPage(), FeedbackPanel.class);
                    annotator.bratRenderLater(aTarget);
                    aTarget.add(numberOfPages);
                    gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                            bratAnnotatorModel.getSentenceAddress()) + 1);
                    aTarget.add(gotoPageTextField);
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    });
    gotoPageTextField.setType(Integer.class);
    gotoPageTextField.setMinimum(1);
    gotoPageTextField.setDefaultModelObject(1);
    add(gotoPageTextFieldForm.add(gotoPageTextField));

    gotoPageTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 56637289242712170L;

        @Override
        protected void onUpdate(AjaxRequestTarget aTarget) {
            try {
                if (gotoPageTextField.getModelObject() < 1) {
                    aTarget.appendJavaScript("alert('Page number shouldn't be less than 1')");
                } else {
                    updateSentenceAddress(getJCas(), aTarget);
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    });

    add(new AjaxLink<Void>("gotoPageLink") {
        private static final long serialVersionUID = 7496156015186497496L;

        @Override
        public void onClick(AjaxRequestTarget aTarget) {
            try {
                if (gotoPageAddress == 0) {
                    aTarget.appendJavaScript("alert('The sentence number entered is not valid')");
                    return;
                }
                if (bratAnnotatorModel.getDocument() == null) {
                    aTarget.appendJavaScript("alert('Please open a document first!')");
                    return;
                }
                if (bratAnnotatorModel.getSentenceAddress() != gotoPageAddress) {
                    bratAnnotatorModel.setSentenceAddress(gotoPageAddress);

                    JCas jCas = getJCas();

                    Sentence sentence = selectByAddr(jCas, Sentence.class, gotoPageAddress);
                    bratAnnotatorModel.setSentenceBeginOffset(sentence.getBegin());
                    bratAnnotatorModel.setSentenceEndOffset(sentence.getEnd());

                    aTarget.addChildren(getPage(), FeedbackPanel.class);
                    annotator.bratRenderLater(aTarget);
                    aTarget.add(numberOfPages);
                    gotoPageTextField.setModelObject(BratAjaxCasUtil.getFirstSentenceNumber(jCas,
                            bratAnnotatorModel.getSentenceAddress()) + 1);
                    aTarget.add(gotoPageTextField);
                }
            } catch (Exception e) {
                error(e.getMessage());
                aTarget.addChildren(getPage(), FeedbackPanel.class);
            }
        }
    });

    finish = new FinishImage("finishImage", new Model<BratAnnotatorModel>(bratAnnotatorModel));
    finish.setOutputMarkupId(true);

    add(new FinishLink("showYesNoModalPanel", new Model<BratAnnotatorModel>(bratAnnotatorModel), finish) {
        private static final long serialVersionUID = -4657965743173979437L;
    });
}

From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.MapConfigServiceBean.java

private void updateLayer(List<? extends LayersDto> layers, List<ServiceLayerEntity> serviceLayers,
        String bingApiKey) {/*from  ww w.j  a v a  2  s  .c o  m*/
    if (layers != null) {
        List<LayersDto> layersToExclude = new ArrayList<>();
        for (LayersDto layersDto : layers) {
            for (ServiceLayerEntity serviceLayerEntity : serviceLayers) {
                if (Long.parseLong(layersDto.getServiceLayerId()) == serviceLayerEntity.getId()) {
                    if (serviceLayerEntity.getProviderFormat() != null
                            && PROVIDER_FORMAT_BING
                                    .equalsIgnoreCase(serviceLayerEntity.getProviderFormat().getServiceType())
                            && bingApiKey == null) {
                        layersToExclude.add(layersDto);
                    } else {
                        layersDto.setName(serviceLayerEntity.getName());
                        layersDto.setSubType(serviceLayerEntity.getSubType());
                        layersDto.setAreaLocationTypeName(serviceLayerEntity.getAreaType().getTypeName());
                    }
                    break;
                }
            }
        }
        layers.removeAll(layersToExclude);
    }
    sortLayer(layers);
}