Search in sources :

Example 6 with PrivateDataInfo

use of com.att.aro.core.peripheral.pojo.PrivateDataInfo in project VideoOptimzer by attdevsupport.

the class UserPreferencesTest method testSetPrivateData.

@Test
public void testSetPrivateData() {
    PrivateDataInfo phoneNumber = new PrivateDataInfo();
    phoneNumber.setCategory("KEYWORD");
    phoneNumber.setType("Phone Number");
    phoneNumber.setValue("123-123-1234");
    phoneNumber.setSelected(true);
    PrivateDataInfo somePattern = new PrivateDataInfo();
    somePattern.setCategory("PATTERN");
    somePattern.setType("PATTERNNAME");
    somePattern.setValue("PATTERNVALUE");
    somePattern.setSelected(false);
    List<PrivateDataInfo> privateData = new ArrayList<PrivateDataInfo>();
    privateData.add(phoneNumber);
    privateData.add(somePattern);
    UserPreferences userPrefs = MockUserPreferencesFactory.getInstance().create();
    userPrefs.setPrivateData(privateData);
    IPreferenceHandler mockPrefHandler = userPrefs.getPreferenceHandler();
    String actualPrivateDataPersisted = mockPrefHandler.getPref(PRIVATE_DATA);
    String expectedPrivateDataPersisted = "KEYWORD,Phone Number,123-123-1234,Y;PATTERN,PATTERNNAME,PATTERNVALUE,N";
    assertEquals(expectedPrivateDataPersisted, actualPrivateDataPersisted);
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 7 with PrivateDataInfo

use of com.att.aro.core.peripheral.pojo.PrivateDataInfo in project VideoOptimzer by attdevsupport.

the class TransmissionPrivateDataImpl method getKeywordsFromPreference.

/**
 * get keywords from user preference
 *
 * @param builder
 */
private void getKeywordsFromPreference(SearchingPatternBuilder builder) {
    UserPreferences pref = UserPreferencesFactory.getInstance().create();
    List<PrivateDataInfo> list = pref.getPrivateData();
    if (list != null) {
        for (PrivateDataInfo info : list) {
            if (info.isSelected()) {
                String encodeURL = Util.encodeUrlEncoding(info.getValue());
                builder.add(encodeURL, info.getType());
            }
        }
    }
}
Also used : UserPreferences(com.att.aro.core.preferences.UserPreferences) PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo)

Example 8 with PrivateDataInfo

use of com.att.aro.core.peripheral.pojo.PrivateDataInfo in project VideoOptimzer by attdevsupport.

the class PrivateDataDialog method prepareSerializeUserPreference.

/**
 * prepare data list and set to UserPreference
 * @param entries
 * @return
 */
private List<PrivateDataInfo> prepareSerializeUserPreference(Map<String, KeywordEntry> entries) {
    Set<String> types = entries.keySet();
    List<PrivateDataInfo> infos = new LinkedList<PrivateDataInfo>();
    List<String> errors = new LinkedList<String>();
    for (String type : types) {
        KeywordEntry entry = entries.get(type);
        String text = entries.get(entry.type).textField.getText();
        boolean isSelected = entries.get(entry.type).checkBox.isSelected();
        if (!validatePrivateData(text) && isSelected) {
            errors.add(entry.type);
            continue;
        }
        PrivateDataInfo info = new PrivateDataInfo();
        info.setCategory(TraceDataConst.PrivateData.KEYWORD_CATEGORY);
        info.setType(entry.type);
        info.setValue(text);
        info.setSelected(isSelected);
        infos.add(info);
    }
    if (errors.isEmpty()) {
        return infos;
    } else {
        errorMessage = getErrorMessage(errors);
        return null;
    }
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) LinkedList(java.util.LinkedList)

Example 9 with PrivateDataInfo

use of com.att.aro.core.peripheral.pojo.PrivateDataInfo in project VideoOptimzer by attdevsupport.

the class PrivateDataDialog method setSelectAllCheckboxSelected.

/**
 * initiate select all check box to be checked if all the entries have been checked
 * @param infos
 * @param selectAllCheckbox
 */
private void setSelectAllCheckboxSelected(List<PrivateDataInfo> infos, JCheckBox selectAllCheckbox) {
    totalEntries = infos.size();
    totalSelected = 0;
    for (PrivateDataInfo info : infos) {
        if (info.isSelected()) {
            totalSelected++;
        }
    }
    selectAllCheckbox.setSelected((totalEntries == 0) ? false : (totalSelected == totalEntries));
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo)

Example 10 with PrivateDataInfo

use of com.att.aro.core.peripheral.pojo.PrivateDataInfo in project VideoOptimzer by attdevsupport.

the class PrivateDataDialog method setCustomizedEntries.

/**
 * set customized entries
 * @param infos
 */
private void setCustomizedEntries(List<PrivateDataInfo> infos) {
    for (PrivateDataInfo info : infos) {
        if (TraceDataConst.PrivateData.KEYWORD_CATEGORY.equals(info.getCategory()) && !defaultKeywords.contains(info.getType())) {
            KeywordEntry entry = initKeywordEntry(info);
            privateDataListPanel.add(getKeywordEntryGrid(entry, true));
            entries.put(entry.type, entry);
        }
    }
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo)

Aggregations

PrivateDataInfo (com.att.aro.core.peripheral.pojo.PrivateDataInfo)13 UserPreferences (com.att.aro.core.preferences.UserPreferences)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 BaseTest (com.att.aro.core.BaseTest)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 Test (org.junit.Test)1