Example usage for com.google.gwt.http.client URL encodeQueryString

List of usage examples for com.google.gwt.http.client URL encodeQueryString

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encodeQueryString.

Prototype

public static String encodeQueryString(String decodedURLComponent) 

Source Link

Document

Returns a string where all characters that are not valid for a URL component have been escaped.

Usage

From source file:org.eclipse.kapua.app.console.client.device.DevicesTable.java

License:Open Source License

private void export(String format) {
    StringBuilder sbUrl = new StringBuilder();
    if (UserAgentUtils.isSafari() || UserAgentUtils.isChrome()) {
        sbUrl.append("console/exporter_device?");
    } else {//w  w w.  j  a  v a 2s . c o m
        sbUrl.append("exporter_device?");
    }

    sbUrl.append("format=").append(format).append("&account=")
            .append(URL.encodeQueryString(m_currentSession.getSelectedAccount().getName()));

    //
    // Adding filtering parameter if specified
    Long tag = m_filterPredicates.getTag();
    if (tag != null) {
        sbUrl.append("&tag=").append(tag);
    }

    String clientId = m_filterPredicates.getClientId();
    if (clientId != null && !clientId.isEmpty()) {
        sbUrl.append("&clientId=").append(clientId);
    }

    String displayName = m_filterPredicates.getDisplayName();
    if (displayName != null && !displayName.isEmpty()) {
        sbUrl.append("&displayName=").append(displayName);
    }

    String serialNumber = m_filterPredicates.getSerialNumber();
    if (serialNumber != null && !serialNumber.isEmpty()) {
        sbUrl.append("&serialNumber=").append(serialNumber);
    }

    String deviceStatus = m_filterPredicates.getDeviceStatus();
    if (deviceStatus != null && !deviceStatus.isEmpty()) {
        sbUrl.append("&deviceStatus=").append(deviceStatus);
    }

    String deviceConnectionStatus = m_filterPredicates.getDeviceConnectionStatus();
    if (deviceConnectionStatus != null && !deviceConnectionStatus.isEmpty()) {
        sbUrl.append("&deviceConnectionStatus=").append(deviceConnectionStatus);
    }

    String esfVersion = m_filterPredicates.getEsfVersion();
    if (esfVersion != null && !esfVersion.isEmpty()) {
        sbUrl.append("&esfVersion=").append(esfVersion);
    }

    String applicationIdentifiers = m_filterPredicates.getApplicationIdentifiers();
    if (applicationIdentifiers != null && !applicationIdentifiers.isEmpty()) {
        sbUrl.append("&applicationIdentifiers=").append(applicationIdentifiers);
    }

    String imei = m_filterPredicates.getImei();
    if (imei != null && !imei.isEmpty()) {
        sbUrl.append("&imei=").append(imei);
    }

    String imsi = m_filterPredicates.getImsi();
    if (imsi != null && !imsi.isEmpty()) {
        sbUrl.append("&imsi=").append(imsi);
    }

    String iccid = m_filterPredicates.getIccid();
    if (iccid != null && !iccid.isEmpty()) {
        sbUrl.append("&iccid=").append(iccid);
    }

    String customAttribute1 = m_filterPredicates.getCustomAttribute1();
    if (customAttribute1 != null && !customAttribute1.isEmpty()) {
        sbUrl.append("&customAttribute1=").append(customAttribute1);
    }

    String customAttribute2 = m_filterPredicates.getCustomAttribute2();
    if (customAttribute2 != null && !customAttribute2.isEmpty()) {
        sbUrl.append("&customAttribute2=").append(customAttribute2);
    }

    Long signedCertificateId = m_filterPredicates.getSignedCertificateId();
    if (signedCertificateId != null) {
        sbUrl.append("&signedCertificateId=").append(signedCertificateId);
    }

    String sortOrder = m_filterPredicates.getSortOrder();
    if (sortOrder != null && !sortOrder.isEmpty()) {
        sbUrl.append("&sortOrder=").append(sortOrder);
    }

    String sortAttribute = m_filterPredicates.getSortAttribute();
    if (sortAttribute != null && !sortAttribute.isEmpty()) {
        sbUrl.append("&sortAttribute=").append(sortAttribute);
    }

    Window.open(sbUrl.toString(), "_blank", "location=no");
}

From source file:org.eclipse.kapua.app.console.client.device.DeviceTabHistory.java

License:Open Source License

private void export(String format) {
    StringBuilder sbUrl = new StringBuilder();
    if (UserAgentUtils.isSafari() || UserAgentUtils.isChrome()) {
        sbUrl.append("console/exporter_device_event?");
    } else {// w w w. j  a  va 2s.  co m
        sbUrl.append("exporter_device_event?");
    }

    sbUrl.append("format=").append(format).append("&account=")
            .append(URL.encodeQueryString(m_currentSession.getSelectedAccount().getName())).append("&clientId=")
            .append(URL.encodeQueryString(m_selectedDevice.getClientId())).append("&startDate=")
            .append(m_dateRangeSelector.getStartDate().getTime()).append("&endDate=")
            .append(m_dateRangeSelector.getEndDate().getTime());
    Window.open(sbUrl.toString(), "_blank", "location=no");
}

From source file:org.eclipse.kura.web.client.ui.Settings.SnapshotsTabUi.java

License:Open Source License

private void downloadSnapshot(String tokenId) {
    final StringBuilder sbUrl = new StringBuilder();

    Long snapshot = this.selected.getSnapshotId();
    sbUrl.append("/" + GWT.getModuleName() + "/device_snapshots?").append("snapshotId=").append(snapshot)
            .append("&").append("xsrfToken=").append(URL.encodeQueryString(tokenId));

    downloadFile(sbUrl.toString());//from w  ww.  j  av a2s.  c om
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.AssessmentsPlayerPresenter.java

License:Open Source License

public String getSearchKeyword() {
    String keyword = null;//  w  ww.j ava 2s .c o  m
    PlaceRequest placeRequest = AppClientFactory.getPlaceManager().getPreviousPlayerRequestUrl();
    if (placeRequest != null) {
        if (placeRequest.getNameToken().equalsIgnoreCase(PlaceTokens.COLLECTION_SEARCH)) {
            keyword = placeRequest.getParameter("query", null);
            keyword = URL.encodeQueryString(keyword);
        }
    }
    return keyword;
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.AssessmentsResourcePlayerPresenter.java

License:Open Source License

public String getSearchKeyword() {
    String keyword = null;/*from www  .j  a va  2  s  .c om*/
    PlaceRequest placeRequest = AppClientFactory.getPlaceManager().getPreviousPlayerRequestUrl();
    if (placeRequest != null) {
        if (placeRequest.getNameToken().equalsIgnoreCase(PlaceTokens.SEARCH_RESOURCE)) {
            keyword = placeRequest.getParameter("query", null);
            keyword = URL.encodeQueryString(keyword);
        }
    }
    return keyword;
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.HotSpotAnswersQuestionView.java

License:Open Source License

private void showCorrectResult() {
    int widgetCount = optionsContainer.getWidgetCount();
    boolean hsChoiceStatus = true;
    Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
    List<Integer> answerIds = new ArrayList<Integer>();
    List<String> userAttemptedValueList = new ArrayList<String>();
    List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();

    for (int i = 0; i < widgetCount; i++) {
        Widget widget = optionsContainer.getWidget(i);
        if (widget instanceof HSAnswerOptionView) {
            HSAnswerOptionView questionAnswerOptionView = (HSAnswerOptionView) widget;

            AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
            attempteAnswersDo.setAttemptResult(questionAnswerOptionView.isAnswerCorrect());
            attempteAnswersDo.setAnswerId(questionAnswerOptionView.getAnswerId());

            AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
            answerAttemptDo.setText(URL.encodeQueryString(questionAnswerOptionView.getAnswerText()));
            answerAttemptDo.setAnswerId(questionAnswerOptionView.getAnswerId());
            answerAttemptDo.setOrder(i + 1 + "");
            answerIds.add(i + 1);// w w  w .  j av  a  2 s  .  c  om

            if (questionAnswerOptionView.isChecked) {

                if (questionAnswerOptionView.isAnswerCorrect()) {
                    if (hsChoiceStatus) {
                        hsChoiceStatus = true;
                    }
                    answerAttemptDo.setStatus("1");
                    answerOptionResult.put(questionAnswerOptionView.getAnswerId(), true);
                    userAttemptedValueList.add("1");
                } else {
                    hsChoiceStatus = false;
                    answerOptionResult.put(questionAnswerOptionView.getAnswerId(), false);
                    userAttemptedValueList.add("0");
                    answerAttemptDo.setStatus("0");
                }

            } else if (!questionAnswerOptionView.isChecked && questionAnswerOptionView.isAnswerCorrect()) {
                hsChoiceStatus = false;
                answerAttemptDo.setStatus("skipped");
            }

            setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
            attempteAnswersDo.setAnswerOptionResult(answerOptionResult);
            userAttemptedOptionsList.add(answerAttemptDo);

        } else if (widget instanceof AddAnswerImg) {
            AddAnswerImg answerImg = (AddAnswerImg) widget;

            AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
            attempteAnswersDo.setAttemptResult(answerImg.isAnswerCorrect());
            attempteAnswersDo.setAnswerId(answerImg.getAnswerId());
            AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
            answerAttemptDo.setText(answerImg.getAnswerImage());
            answerAttemptDo.setAnswerId(answerImg.getAnswerId());
            answerAttemptDo.setOrder(i + 1 + "");
            answerIds.add(i + 1);

            if (answerImg.selectedImage) {
                if (answerImg.isAnswerCorrect()) {
                    if (hsChoiceStatus) {
                        hsChoiceStatus = true;
                    }
                    answerAttemptDo.setStatus("1");
                    answerOptionResult.put(answerImg.getAnswerId(), true);
                    userAttemptedValueList.add("1");
                } else {
                    hsChoiceStatus = false;
                    answerOptionResult.put(answerImg.getAnswerId(), false);
                    userAttemptedValueList.add("0");
                    answerAttemptDo.setStatus("0");
                }

            } else if (!answerImg.selectedImage && answerImg.isAnswerCorrect()) {
                hsChoiceStatus = false;
                answerAttemptDo.setStatus("skipped");
            }
            setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
            attempteAnswersDo.setAnswerOptionResult(answerOptionResult);
            userAttemptedOptionsList.add(answerAttemptDo);

        }
    }
    userAttemptedAnswerObject(userAttemptedOptionsList);
    increaseUserAttemptCount();

    String attemptStatus = hsChoiceStatus == true ? "correct" : "wrong";
    int score = 0;
    boolean isFirstTry = isCheckAnswerButtonClicked;
    isCheckAnswerButtonClicked = true;
    score = hsChoiceStatus ? 1 : 0;
    userAttemptedValue(userAttemptedValueList);
    setAnswersDetailsWitithTime(answerIds, hsChoiceStatus ? 1 : 0, 1, score, !isFirstTry);
    createSesstionItemAttemptForMultipleAnswer(answerIds, userAttemptedValueList, attemptStatus);
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.HotTextAnswersQuestionView.java

License:Open Source License

private void showCorrectResult() {

    if (collectionItemDo.getResource().getType() == 9) {

        boolean HTDragChoiceStatus = true;
        List<Integer> answerIds = new ArrayList<Integer>();
        List<String> userAttemptedValueList = new ArrayList<String>();
        Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
        List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();
        int j = 0;
        for (int i = 0; i < optionsContainer.getWidgetCount(); i++) {
            Widget widget = optionsContainer.getWidget(i);
            Element el = (Element) widget.getElement().getLastChild();
            if (widget instanceof Draggable && el != null && !el.getId().equalsIgnoreCase("")) {
                Draggable draggable = (Draggable) widget;
                HTAnswerChoiceOptionView htAnswerOption = (HTAnswerChoiceOptionView) draggable.getWidget();
                String answerText = URL.encodeQueryString(htAnswerOption.getAnswerText());
                userAttemptedValueList.add(answerText);
                AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
                if (el != null && el.getId() != null && !el.getId().equalsIgnoreCase("")) {
                    answerIds.add(Integer.parseInt(el.getId()) + 1);
                    if (el.getId().equalsIgnoreCase(correctAnsSequence[j])) {
                        //el.addClassName(STYLE_DND_CORRECT);
                        answerOptionResult.put(Integer.parseInt(el.getId()), true);
                        answerAttemptDo.setStatus("1");
                    } else {
                        //el.addClassName(STYLE_DND_INCORRECT);
                        HTDragChoiceStatus = false;
                        answerOptionResult.put(Integer.parseInt(el.getId()), false);
                        answerAttemptDo.setStatus("0");
                    }/*from  w  w  w.  j a  va  2 s .com*/
                    j++;
                }
                answerAttemptDo.setText(answerText);
                answerAttemptDo.setAnswerId(0);
                answerAttemptDo.setOrder("0");

                userAttemptedOptionsList.add(answerAttemptDo);
            }

        }

        AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
        if (collectionItemDo.getResource() != null && collectionItemDo.getResource().getType() != null) {
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
        }
        attempteAnswersDo.setAnswerOptionResult(answerOptionResult);

        setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
        userAttemptedAnswerObject(userAttemptedOptionsList);
        increaseUserAttemptCount();

        String attemptStatus = HTDragChoiceStatus == true ? "correct" : "wrong";
        int score = HTDragChoiceStatus == true ? 1 : 0;
        createSesstionItemAttemptForHTDragDrop(answerIds, userAttemptedValueList, attemptStatus);
        userAttemptedValue(userAttemptedValueList);
        setAnswerAttemptSequence(1, score, 0);

        boolean isFirstTry = isCheckAnswerButtonClicked;
        isCheckAnswerButtonClicked = true;

        setAnswersDetailsWitithTime(answerIds, HTDragChoiceStatus ? 1 : 0, 1, score, !isFirstTry);

    } else {

        boolean HTHLChoiceStatus = true;
        List<Integer> answerIds = new ArrayList<Integer>();
        List<String> userAttemptedValueList = new ArrayList<String>();
        Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
        List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();

        AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
        String answerText = "";
        HTML ansText = new HTML();
        for (int i = 0; i < optionsContainerFpnl.getWidgetCount(); i++) {

            InlineLabel oldLbl = (InlineLabel) optionsContainerFpnl.getWidget(i);

            InlineLabel lbl = new InlineLabel(oldLbl.getText());
            lbl.addStyleName(oldLbl.getStyleName());
            lbl.getElement().setId(oldLbl.getElement().getId());
            answerIds.add(i + 1);
            if (lbl.getStyleName().contains(STYLE_HIGHLIGHT)) {

                if (lbl.getElement().getId().equalsIgnoreCase(STYLE_CORRECT)) {
                    lbl.addStyleName(STYLE_CORRECT);
                    answerOptionResult.put(1, true);
                    answerAttemptDo.setStatus("1");

                } else {
                    lbl.addStyleName(STYLE_INCORRECT);
                    answerOptionResult.put(0, true);
                    answerAttemptDo.setStatus("0");
                    HTHLChoiceStatus = false;

                }
            } else if (!lbl.getStyleName().contains(STYLE_HIGHLIGHT)
                    && lbl.getElement().getId().equalsIgnoreCase(STYLE_CORRECT)) {
                HTHLChoiceStatus = false;
            } else {
                //answerText=answerText+lbl.getText();
            }
            answerText = answerText + lbl.toString();
            ansText.setHTML(lbl.toString());
        }
        ansText.setHTML(answerText);
        userAttemptedValueList.add(URL.encodeQueryString(ansText.toString()));
        answerAttemptDo.setText(URL.encodeQueryString(ansText.toString()));
        answerAttemptDo.setAnswerId(0);
        answerAttemptDo.setOrder("0");
        userAttemptedOptionsList.add(answerAttemptDo);
        AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
        if (collectionItemDo.getResource() != null && collectionItemDo.getResource().getType() != null) {
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
        }
        attempteAnswersDo.setAnswersText(URL.encodeQueryString(optionsContainerFpnl.toString()));
        attempteAnswersDo.setAnswerOptionResult(answerOptionResult);

        setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);

        userAttemptedAnswerObject(userAttemptedOptionsList);
        increaseUserAttemptCount();

        String attemptStatus = HTHLChoiceStatus == true ? "correct" : "wrong";
        int score = HTHLChoiceStatus == true ? 1 : 0;
        createSesstionItemAttemptForHTDragDrop(answerIds, userAttemptedValueList, attemptStatus);
        userAttemptedValue(userAttemptedValueList);
        setAnswerAttemptSequence(1, score, 0);

        boolean isFirstTry = isCheckAnswerButtonClicked;
        isCheckAnswerButtonClicked = true;

        setAnswersDetailsWitithTime(answerIds, HTHLChoiceStatus ? 1 : 0, 1, score, !isFirstTry);
    }

    isUserAnswerAttempted(true);
}

From source file:org.ednovo.gooru.client.mvp.play.resource.question.HotSpotAnswersQuestionView.java

License:Open Source License

private void showCorrectResult() {
    int widgetCount = optionsContainer.getWidgetCount();
    boolean hsChoiceStatus = true;
    Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
    List<Integer> answerIds = new ArrayList<Integer>();
    List<String> userAttemptedValueList = new ArrayList<String>();
    List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();

    for (int i = 0; i < widgetCount; i++) {
        Widget widget = optionsContainer.getWidget(i);
        if (widget instanceof HSAnswerOptionView) {
            HSAnswerOptionView questionAnswerOptionView = (HSAnswerOptionView) widget;

            AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
            attempteAnswersDo.setAttemptResult(questionAnswerOptionView.isAnswerCorrect());
            attempteAnswersDo.setAnswerId(questionAnswerOptionView.getAnswerId());

            AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
            answerAttemptDo.setText(URL.encodeQueryString(questionAnswerOptionView.getAnswerText()));
            //answerAttemptDo.setText(StringUtil.replaceSpecial(questionAnswerOptionView.getAnswerText())); 
            answerAttemptDo.setAnswerId(questionAnswerOptionView.getAnswerId());
            answerAttemptDo.setOrder(i + 1 + "");
            answerIds.add(i + 1);/*from   w  w w . j  a v a 2s.co m*/

            if (questionAnswerOptionView.isChecked) {

                if (questionAnswerOptionView.isAnswerCorrect()) {
                    if (hsChoiceStatus) {
                        hsChoiceStatus = true;
                    }
                    answerAttemptDo.setStatus("1");
                    answerOptionResult.put(questionAnswerOptionView.getAnswerId(), true);
                    userAttemptedValueList.add("1");
                    questionAnswerOptionView.answerChoiceResult.addStyleName(CORRECT_ICON);
                } else {
                    hsChoiceStatus = false;
                    answerOptionResult.put(questionAnswerOptionView.getAnswerId(), false);
                    userAttemptedValueList.add("0");
                    answerAttemptDo.setStatus("0");
                    questionAnswerOptionView.answerChoiceResult.addStyleName(INCORRECT_ICON);
                }

            } else if (!questionAnswerOptionView.isChecked && questionAnswerOptionView.isAnswerCorrect()) {
                hsChoiceStatus = false;
                answerAttemptDo.setStatus("skipped");
            }

            setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
            attempteAnswersDo.setAnswerOptionResult(answerOptionResult);
            userAttemptedOptionsList.add(answerAttemptDo);

        } else if (widget instanceof AddAnswerImg) {
            AddAnswerImg answerImg = (AddAnswerImg) widget;
            AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
            attempteAnswersDo.setAttemptResult(answerImg.isAnswerCorrect());
            attempteAnswersDo.setAnswerId(answerImg.getAnswerId());
            AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
            answerAttemptDo.setText(answerImg.getAnswerImage());
            answerAttemptDo.setAnswerId(answerImg.getAnswerId());
            answerAttemptDo.setOrder(i + 1 + "");
            answerIds.add(i + 1);

            if (answerImg.selectedImage) {

                if (answerImg.isAnswerCorrect()) {
                    if (hsChoiceStatus) {
                        hsChoiceStatus = true;
                    }
                    answerAttemptDo.setStatus("1");
                    answerOptionResult.put(answerImg.getAnswerId(), true);
                    userAttemptedValueList.add("1");
                    answerImg.getElement().addClassName(IMAGE_CORRECT_STYLE);
                } else {
                    hsChoiceStatus = false;
                    answerOptionResult.put(answerImg.getAnswerId(), false);
                    userAttemptedValueList.add("0");
                    answerAttemptDo.setStatus("0");
                    answerImg.getElement().addClassName(IMAGE_INCORRECT_STYLE);
                }

            } else if (!answerImg.selectedImage && answerImg.isAnswerCorrect()) {
                hsChoiceStatus = false;
                answerAttemptDo.setStatus("skipped");
            }

            setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
            attempteAnswersDo.setAnswerOptionResult(answerOptionResult);
            userAttemptedOptionsList.add(answerAttemptDo);
        }
    }
    userAttemptedAnswerObject(userAttemptedOptionsList);
    increaseUserAttemptCount();

    String attemptStatus = hsChoiceStatus == true ? "correct" : "wrong";
    int score = 0;
    boolean isFirstTry = isCheckAnswerButtonClicked;
    isCheckAnswerButtonClicked = true;
    score = hsChoiceStatus ? 1 : 0;
    userAttemptedValue(userAttemptedValueList);
    setAnswersDetailsWitithTime(answerIds, hsChoiceStatus ? 1 : 0, 1, score, !isFirstTry);
    createSesstionItemAttemptForMultipleAnswer(answerIds, userAttemptedValueList, attemptStatus);
}

From source file:org.ednovo.gooru.client.mvp.play.resource.question.HotTextAnswersQuestionView.java

License:Open Source License

private void showCorrectResult() {

    if (collectionItemDo.getResource().getType() == 9) {

        boolean HTDragChoiceStatus = true;
        List<Integer> answerIds = new ArrayList<Integer>();
        List<String> userAttemptedValueList = new ArrayList<String>();
        Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
        List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();
        int j = 0;

        //String answerText="";
        //AnswerAttemptDo answerAttemptDo=new AnswerAttemptDo();
        for (int i = 0; i < optionsContainer.getWidgetCount(); i++) {
            Widget widget = optionsContainer.getWidget(i);
            Element el = (Element) widget.getElement().getLastChild();
            if (widget instanceof Draggable && el != null && !el.getId().equalsIgnoreCase("")) {
                Draggable draggable = (Draggable) widget;
                HTAnswerChoiceOptionView htAnswerOption = (HTAnswerChoiceOptionView) draggable.getWidget();
                String answerText = URL.encodeQueryString(htAnswerOption.getAnswerText());
                userAttemptedValueList.add(answerText);
                AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
                if (el != null && el.getId() != null && !el.getId().equalsIgnoreCase("")) {
                    answerIds.add(Integer.parseInt(el.getId()) + 1);
                    if (el.getId().equalsIgnoreCase(correctAnsSequence[j])) {
                        el.addClassName(STYLE_DND_CORRECT);
                        answerOptionResult.put(Integer.parseInt(el.getId()), true);
                        answerAttemptDo.setStatus("1");
                    } else {
                        el.addClassName(STYLE_DND_INCORRECT);
                        HTDragChoiceStatus = false;
                        answerOptionResult.put(Integer.parseInt(el.getId()), false);
                        answerAttemptDo.setStatus("0");
                    }/*from www  .  j  a va 2  s  . c o  m*/
                    j++;
                }
                answerAttemptDo.setText(answerText);
                answerAttemptDo.setAnswerId(0);
                answerAttemptDo.setOrder("0");

                userAttemptedOptionsList.add(answerAttemptDo);
            }

        }

        AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
        if (collectionItemDo.getResource() != null && collectionItemDo.getResource().getType() != null) {
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
        }
        attempteAnswersDo.setAnswerOptionResult(answerOptionResult);

        setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);
        userAttemptedAnswerObject(userAttemptedOptionsList);
        increaseUserAttemptCount();

        String attemptStatus = HTDragChoiceStatus == true ? "correct" : "wrong";
        int score = HTDragChoiceStatus == true ? 1 : 0;
        createSesstionItemAttemptForHTDragDrop(answerIds, userAttemptedValueList, attemptStatus);
        userAttemptedValue(userAttemptedValueList);
        setAnswerAttemptSequence(1, score, 0);

        boolean isFirstTry = isCheckAnswerButtonClicked;
        isCheckAnswerButtonClicked = true;

        setAnswersDetailsWitithTime(answerIds, HTDragChoiceStatus ? 1 : 0, 1, score, !isFirstTry);

    } else {

        boolean HTHLChoiceStatus = true;
        List<Integer> answerIds = new ArrayList<Integer>();
        List<String> userAttemptedValueList = new ArrayList<String>();
        Map<Integer, Boolean> answerOptionResult = new LinkedHashMap<Integer, Boolean>();
        List<AnswerAttemptDo> userAttemptedOptionsList = new ArrayList<AnswerAttemptDo>();

        AnswerAttemptDo answerAttemptDo = new AnswerAttemptDo();
        String answerText = "";
        HTML ansText = new HTML();
        for (int i = 0; i < optionsContainerFpnl.getWidgetCount(); i++) {

            InlineLabel lbl = (InlineLabel) optionsContainerFpnl.getWidget(i);
            answerIds.add(i + 1);
            if (lbl.getStyleName().contains(STYLE_HIGHLIGHT)) {

                if (lbl.getElement().getId().equalsIgnoreCase(STYLE_CORRECT)) {
                    lbl.addStyleName(STYLE_CORRECT);
                    answerOptionResult.put(1, true);
                    answerAttemptDo.setStatus("1");
                    if (collectionItemDo.getResource().getHlType().equalsIgnoreCase(i18n.GL3219_1())) {
                        //answerText=answerText+START_CORRECT_DELIMITER+lbl.getText().trim()+END_CORRECT_DELIMITER+SPACE;
                    } else {
                        //String inLblTxt=lbl.getText()+END_CORRECT_DELIMITER+DOT;                  
                        if (lbl.getText().trim().lastIndexOf(DOT) == lbl.getText().trim().length() - 1) {
                            //inLblTxt=lbl.getText().replace(DOT, END_CORRECT_DELIMITER+DOT);
                        }
                        //answerText=answerText+START_CORRECT_DELIMITER+inLblTxt;
                    }

                } else {
                    lbl.addStyleName(STYLE_INCORRECT);
                    answerOptionResult.put(0, true);
                    answerAttemptDo.setStatus("0");
                    HTHLChoiceStatus = false;
                    if (collectionItemDo.getResource().getHlType().equalsIgnoreCase(i18n.GL3219_1())) {
                        //answerText=answerText+START_DELIMITER+lbl.getText().trim()+END_DELIMITER+SPACE;
                    } else {

                        /*String inLblTxt=lbl.getText()+END_DELIMITER+DOT;                  
                        if(lbl.getText().trim().lastIndexOf(DOT) ==lbl.getText().trim().length()-1){
                           inLblTxt=lbl.getText().replace(DOT, END_DELIMITER+DOT);
                        }
                        answerText=answerText+START_DELIMITER+inLblTxt;*/
                    }
                }
            } else if (!lbl.getStyleName().contains(STYLE_HIGHLIGHT)
                    && lbl.getElement().getId().equalsIgnoreCase(STYLE_CORRECT)) {
                HTHLChoiceStatus = false;
            } else {
                //answerText=answerText+lbl.getText();
            }
            answerText = answerText + lbl.toString();
            ansText.setHTML(lbl.toString());
        }
        //userAttemptedValueList.add("["+answerText+"]");
        //answerAttemptDo.setText("\""+answerText);
        ansText.setHTML(answerText);
        userAttemptedValueList.add(URL.encodeQueryString(ansText.toString()));
        answerAttemptDo.setText(URL.encodeQueryString(ansText.toString()));
        answerAttemptDo.setAnswerId(0);
        answerAttemptDo.setOrder("0");
        userAttemptedOptionsList.add(answerAttemptDo);
        AttemptedAnswersDo attempteAnswersDo = new AttemptedAnswersDo();
        if (collectionItemDo.getResource() != null && collectionItemDo.getResource().getType() != null) {
            attempteAnswersDo.setQuestionType(collectionItemDo.getResource().getType());
        }
        attempteAnswersDo.setAnswersText(URL.encodeQueryString(optionsContainerFpnl.toString()));
        attempteAnswersDo.setAnswerOptionResult(answerOptionResult);

        setAttemptStatus(collectionItemDo.getCollectionItemId(), attempteAnswersDo);

        userAttemptedAnswerObject(userAttemptedOptionsList);
        increaseUserAttemptCount();

        String attemptStatus = HTHLChoiceStatus == true ? "correct" : "wrong";
        int score = HTHLChoiceStatus == true ? 1 : 0;
        createSesstionItemAttemptForHTDragDrop(answerIds, userAttemptedValueList, attemptStatus);
        userAttemptedValue(userAttemptedValueList);
        setAnswerAttemptSequence(1, score, 0);

        boolean isFirstTry = isCheckAnswerButtonClicked;
        isCheckAnswerButtonClicked = true;

        setAnswersDetailsWitithTime(answerIds, HTHLChoiceStatus ? 1 : 0, 1, score, !isFirstTry);
    }

    isUserAnswerAttempted(true);
}

From source file:org.eobjects.datacleaner.monitor.scheduling.widgets.SchedulePanel.java

License:Open Source License

public SchedulePanel(final ClientConfig clientConfig, final ScheduleDefinition schedule,
        final SchedulingServiceAsync service) {
    super();/*  w  w  w . j a  v  a  2s  .co  m*/

    _clientConfig = clientConfig;
    _schedule = schedule;

    initWidget(uiBinder.createAndBindUi(this));

    // add the job type as a style name
    final String jobType = schedule.getJob().getType();
    if (jobType != null) {
        addStyleName(jobType);
    }

    final boolean analysisJob = JobIdentifier.JOB_TYPE_ANALYSIS_JOB.equals(jobType);

    updateScheduleWidgets();

    final TenantIdentifier tenant = _clientConfig.getTenant();

    final String encodedJobName = URL.encodeQueryString(schedule.getJob().getName());

    if (_clientConfig.isJobEditor()) {
        jobLabel.addClickHandler(new CustomizeJobClickHandler(this, tenant));
    }

    if (_clientConfig.isScheduleEditor()) {
        CustomizeScheduleClickHandler handler = new CustomizeScheduleClickHandler(this, service, tenant,
                schedule);
        scheduleAnchor.addClickHandler(handler);

        final String token = History.getToken();
        GWT.log("Encoded job name: " + encodedJobName);
        if (("schedule_" + encodedJobName).equals(token)) {
            History.newItem("");
            handler.showSchedulingPopup();
        }
    }

    if (!_clientConfig.isJobEditor()) {
        alertsPanel.setVisible(false);
    }

    if (_clientConfig.isScheduleEditor()) {
        TriggerJobClickHandler handler = new TriggerJobClickHandler(service, tenant, _schedule);
        triggerNowButton.addClickHandler(handler);

        final String token = History.getToken();
        if (("trigger_" + encodedJobName).equals(token)) {
            History.newItem("");
            handler.showExecutionPopup();
        }
    }

    if (_clientConfig.isJobEditor() && analysisJob) {
        launchButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                String url = Urls.createRepositoryUrl(tenant,
                        "jobs/" + schedule.getJob().getName() + ".launch.jnlp");
                Window.open(url, "_blank", null);
            }
        });
    } else {
        launchButton.setVisible(false);
    }

    historyButton.addClickHandler(new JobHistoryClickHandler(service, tenant, schedule));

    final List<AlertDefinition> alerts = schedule.getAlerts();
    final Anchor expandAlertsAnchor = new Anchor(alerts.size() + " alert(s)");
    if (alerts.isEmpty()) {
        expandAlertsAnchor.addStyleName("discrete");
    }
    expandAlertsAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final FlowPanel alertListPanel = new FlowPanel();
            alertListPanel.setStyleName("AlertListPanel");

            if (alerts.isEmpty()) {
                Label label = new Label("(no alerts)");
                label.setStylePrimaryName("AlertPanel");
                alertListPanel.add(label);
            }
            for (AlertDefinition alert : alerts) {
                AlertPanel alertPanel = new AlertPanel(service, schedule, alert);
                alertListPanel.add(alertPanel);
            }

            alertsPanel.clear();
            alertsPanel.add(new CreateAlertAnchor(service, schedule));
            alertsPanel.add(alertListPanel);
        }
    });
    alertsPanel.add(expandAlertsAnchor);
}