Search in sources :

Example 1 with PrivateDataInfo

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

the class UserPreferences method getPrivateData.

public List<PrivateDataInfo> getPrivateData() {
    List<PrivateDataInfo> privateDataInfoList = new ArrayList<PrivateDataInfo>();
    String privateDataflattened = prefHandler.getPref(PRIVATE_DATA);
    if (privateDataflattened == null) {
        return privateDataInfoList;
    }
    String[] privateDataInfoArr = privateDataflattened.split(TraceDataConst.PrivateData.ITEM_DELIMITER);
    for (String privateDataInfo : privateDataInfoArr) {
        String[] properties = privateDataInfo.split(TraceDataConst.PrivateData.COLUMN_DELIMITER);
        String category = properties[0];
        String type = properties[1];
        String value = properties[2];
        boolean selected = TraceDataConst.PrivateData.YES_SELECTED.equals(properties[3]) ? true : false;
        PrivateDataInfo info = new PrivateDataInfo();
        info.setCategory(category);
        info.setType(type);
        info.setValue(value);
        info.setSelected(selected);
        privateDataInfoList.add(info);
    }
    return privateDataInfoList;
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) ArrayList(java.util.ArrayList)

Example 2 with PrivateDataInfo

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

the class PrivateDataDialog method getPrivateDataListPanel.

/**
 * private data list panel contains select all panel, and private data entries, which are default entries and customized entries
 * @return
 */
private JPanel getPrivateDataListPanel() {
    if (privateDataListPanel == null) {
        privateDataListPanel = new JPanel();
        entries = new HashMap<String, KeywordEntry>();
        removeToType = new HashMap<JButton, String>();
        privateDataListPanel.setLayout(new BoxLayout(privateDataListPanel, BoxLayout.Y_AXIS));
        // add panel contains "select all" check box
        privateDataListPanel.add(getSelectAllPanel());
        List<PrivateDataInfo> infos = deserializeUserPreference();
        setDefaultEntries(infos);
        setCustomizedEntries(infos);
        setSelectAllCheckboxSelected(infos, selectAllCheckbox);
    }
    return privateDataListPanel;
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton)

Example 3 with PrivateDataInfo

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

the class PrivateDataDialog method setDefaultEntries.

/**
 * set default entries
 * @param infos
 */
private void setDefaultEntries(List<PrivateDataInfo> infos) {
    Map<String, PrivateDataInfo> buffer = new HashMap<>();
    for (PrivateDataInfo info : infos) {
        buffer.put(info.getType(), info);
    }
    for (String keyword : defaultKeywords) {
        PrivateDataInfo info;
        if (buffer.containsKey(keyword)) {
            info = buffer.get(keyword);
        } else {
            info = new PrivateDataInfo();
            info.setCategory(TraceDataConst.PrivateData.KEYWORD_CATEGORY);
            info.setType(keyword);
        }
        KeywordEntry entry = initKeywordEntry(info);
        privateDataListPanel.add(getKeywordEntryGrid(entry, false));
        entries.put(entry.type, entry);
    }
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) HashMap(java.util.HashMap)

Example 4 with PrivateDataInfo

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

the class PrivateDataReaderImpl method processLine.

/**
 * format of private data line in the file
 * [category],[type],[value],[isSelected]
 *
 * e.g.:
 *
 * KEYWORD,PHONE NUMBER,(443)-234-5678,Y
 *
 * @param line
 * @return
 */
private PrivateDataInfo processLine(String line) {
    PrivateDataInfo privateDataInfo = null;
    try {
        String[] tokens = line.split(DELIMITER);
        privateDataInfo = new PrivateDataInfo();
        privateDataInfo.setCategory(tokens[0].trim());
        privateDataInfo.setType(tokens[1].trim());
        privateDataInfo.setValue(tokens[2].trim());
        boolean isSelected = TraceDataConst.PrivateData.YES_SELECTED.equals(tokens[3].trim()) ? true : false;
        privateDataInfo.setSelected(isSelected);
        return privateDataInfo;
    } catch (Exception e) {
        LOGGER.error("Invalid format of pattern from user setting: " + line);
        return null;
    }
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo)

Example 5 with PrivateDataInfo

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

the class PrivateDataReaderImpl method readData.

@Override
public List<PrivateDataInfo> readData(String directory) {
    List<PrivateDataInfo> privateDataInfos = new LinkedList<PrivateDataInfo>();
    String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.PRIVATE_DATA_FILE;
    if (!filereader.fileExist(filePath)) {
        return privateDataInfos;
    }
    String[] lines = null;
    try {
        lines = filereader.readAllLine(filePath);
    } catch (Exception e) {
        LOGGER.error("failed to read private data info file: " + filePath);
    }
    if (lines != null && lines.length != 0) {
        for (String line : lines) {
            PrivateDataInfo privateDataInfo = processLine(line);
            if (privateDataInfo != null) {
                privateDataInfos.add(privateDataInfo);
            }
        }
    }
    return privateDataInfos;
}
Also used : PrivateDataInfo(com.att.aro.core.peripheral.pojo.PrivateDataInfo) LinkedList(java.util.LinkedList)

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