Search in sources :

Example 1 with VideoUsagePrefs

use of com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs in project VideoOptimzer by attdevsupport.

the class VideoPreferenceModel method updatePreferenceAndTable.

private boolean updatePreferenceAndTable(int row, VideoPreferenceInfo videoPref) {
    mapper = new ObjectMapper();
    prefs = PreferenceHandlerImpl.getInstance();
    String temp = "";
    if (videoUsagePrefs == null) {
        temp = prefs.getPref(VideoUsagePrefs.VIDEO_PREFERENCE);
        if (temp != null && !temp.equals("null")) {
            try {
                videoUsagePrefs = mapper.readValue(temp, VideoUsagePrefs.class);
            } catch (IOException e) {
                LOGGER.error("VideoUsagePrefs failed to de-serialize :" + e.getMessage());
            }
        } else {
            try {
                videoUsagePrefs = ContextAware.getAROConfigContext().getBean("videoUsagePrefs", VideoUsagePrefs.class);
                temp = mapper.writeValueAsString(videoUsagePrefs);
                prefs.setPref(VideoUsagePrefs.VIDEO_PREFERENCE, temp);
            } catch (IOException e) {
                LOGGER.error("VideoUsagePrefs failed to serialize :" + e.getMessage());
            }
        }
    }
    switch(row) {
        case // StartUp DeSTARTUP_DELAY_ROWay
        STARTUP_DELAY_ROW:
            videoUsagePrefs.setStartUpDelayWarnVal(videoPref.getWarningCriteria());
            break;
        case // Stall Duration
        STALL_DURATION_ROW:
            videoUsagePrefs.setStallDurationWarnVal(videoPref.getWarningCriteria());
            videoUsagePrefs.setStallDurationFailVal(videoPref.getFailCriteria());
            break;
        case // Segment Redundancy
        SEGMENT_REDUNDANCY_ROW:
            videoUsagePrefs.setSegmentRedundancyWarnVal(videoPref.getWarningCriteriaInt());
            videoUsagePrefs.setSegmentRedundancyFailVal(videoPref.getFailCriteriaInt());
            break;
    }
    // prefs.setPref(VideoUsagePrefs.VIDEO_PREFERENCE, temp);
    videoPreferenceList.set(row, videoPref);
    return true;
}
Also used : IOException(java.io.IOException) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with VideoUsagePrefs

use of com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs in project VideoOptimzer by attdevsupport.

the class VideoUsagePrefsManagerImpl method getVideoUsagePreference.

public VideoUsagePrefs getVideoUsagePreference() {
    PreferenceHandlerImpl prefs = PreferenceHandlerImpl.getInstance();
    String videoPref = prefs.getPref(VideoUsagePrefs.VIDEO_PREFERENCE);
    if (videoPref != null && !videoPref.equals("null")) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            videoUsagePrefs = mapper.readValue(videoPref, VideoUsagePrefs.class);
        } catch (IOException e) {
            LOG.error("VideoPreference Mapper Exception" + e.getMessage());
        }
    }
    return videoUsagePrefs;
}
Also used : PreferenceHandlerImpl(com.att.aro.core.preferences.impl.PreferenceHandlerImpl) IOException(java.io.IOException) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with VideoUsagePrefs

use of com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs in project VideoOptimzer by attdevsupport.

the class VideoPrefsController method loadPrefs.

/**
 * Loads video preferences set in the config file onto VideoUsagePrefs
 */
public VideoUsagePrefs loadPrefs() {
    ObjectMapper mapper = new ObjectMapper();
    videoUsagePrefs = new VideoUsagePrefs();
    String temp = prefs.getPref(VideoUsagePrefs.VIDEO_PREFERENCE);
    if (temp != null && !temp.equals("null")) {
        try {
            videoUsagePrefs = mapper.readValue(temp, VideoUsagePrefs.class);
        } catch (IOException e) {
            LOG.error("VideoUsagePrefs failed to de-serialize :" + e.getMessage());
        }
    } else {
        try {
            temp = mapper.writeValueAsString(videoUsagePrefs);
            prefs.setPref(VideoUsagePrefs.VIDEO_PREFERENCE, temp);
        } catch (IOException e) {
            LOG.error("VideoUsagePrefs failed to serialize :" + e.getMessage());
        }
    }
    return videoUsagePrefs;
}
Also used : IOException(java.io.IOException) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with VideoUsagePrefs

use of com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs in project VideoOptimzer by attdevsupport.

the class VideoAnalysisConfigHelperImpl method loadPrefs.

// TODO move this into AroPrefs, a new handler for preferences json serialization
void loadPrefs() {
    Path filePath = Paths.get(folderPath + "prefs.json");
    VideoUsagePrefs videoUsagePrefs = null;
    try {
        String temp = new String(Files.readAllBytes(filePath));
        videoUsagePrefs = mapper.readValue(temp, VideoUsagePrefs.class);
        LOG.debug("videoUsagePrefs :" + videoUsagePrefs);
    } catch (JsonParseException e) {
        LOG.error("VideoUsagePrefs failed to de-serialize :" + e.getMessage());
    } catch (JsonMappingException e) {
        LOG.error("VideoUsagePrefs failed to de-serialize :" + e.getMessage());
    } catch (IOException e) {
        LOG.error("VideoUsagePrefs failed to load :" + e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Example 5 with VideoUsagePrefs

use of com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs in project VideoOptimzer by attdevsupport.

the class VideoPreferencesPanel method loadVideoUsagePreferences.

private void loadVideoUsagePreferences() {
    mapper = new ObjectMapper();
    prefs = PreferenceHandlerImpl.getInstance();
    String temp = prefs.getPref(VideoUsagePrefs.VIDEO_PREFERENCE);
    if (temp != null && !temp.equals("null")) {
        try {
            videoUsagePrefs = mapper.readValue(temp, VideoUsagePrefs.class);
            videoPreferenceModel = new VideoPreferenceModel();
        } catch (IOException e) {
            LOG.error("VideoUsagePrefs failed to de-serialize :" + e.getMessage(), e);
        }
    } else {
        try {
            // new
            videoUsagePrefs = ContextAware.getAROConfigContext().getBean("videoUsagePrefs", VideoUsagePrefs.class);
            // VideoUsagePrefs();
            temp = mapper.writeValueAsString(videoUsagePrefs);
            prefs.setPref(VideoUsagePrefs.VIDEO_PREFERENCE, temp);
        } catch (IOException e) {
            LOG.error("VideoUsagePrefs failed to serialize :" + e.getMessage(), e);
        }
    }
}
Also used : IOException(java.io.IOException) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

VideoUsagePrefs (com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs)5 IOException (java.io.IOException)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 PreferenceHandlerImpl (com.att.aro.core.preferences.impl.PreferenceHandlerImpl)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 Path (java.nio.file.Path)1