notification-portlet-webapp/src/main/java/org/jasig/portlet/notice/service/jpa/JpaNotificationService.java
private NotificationEntry prepareEntry(JpaEntry entry, String username) {

        /*
         * Implementation Note:  Most notification fields are optional.  This
         * method impl avoids setting fields within the NotificationEntry when
         * those fields are (essentially) unspecified on the JpaEntry in order
         * not to run afoul of any logic (present or future) that may trigger
         * when a field is set (e.g. validation, virtual members, change
         * tracking).
         */

        NotificationEntry rslt = new NotificationEntry();

        // Id & title will always be present
        rslt.setId(ID_PREFIX + entry.getId());
        final String title = entry.getTitle();
        if (StringUtils.isBlank(title)) {
            log.warn("User '" + username + "' had a notification with an empty title:  " + entry.toString());
            return null;
        }
        rslt.setTitle(title);

        // But these fields are optional
        if (!StringUtils.isBlank(entry.getBody())) {  // Body
            rslt.setBody(entry.getBody());
        }
        if (entry.getDueDate() != null) {  // Due date
            rslt.setDueDate(entry.getDueDate());
        }
        if (!StringUtils.isBlank(entry.getImage())) {  // Image
            rslt.setImage(entry.getImage());
        }
        if (!StringUtils.isBlank(entry.getLinkText())) {  // Link text
            rslt.setLinkText(entry.getLinkText());
        }
        if (entry.getPriority() != 0) {  // Priority
            rslt.setPriority(entry.getPriority());
        }
        if (!StringUtils.isBlank(entry.getSource())) {  // Source
            rslt.setSource(entry.getSource());
        }
        if (!StringUtils.isBlank(entry.getUrl())) {  // Url
            rslt.setUrl(entry.getUrl());
        }

        // States (transaction log)
        Map<NotificationState,Date> states = prepareStates(entry, username);
        rslt.setStates(states);

        // Collections of items...
        if (!entry.getAttributes().isEmpty()) {  // Attributes
            List<NotificationAttribute> attributes = prepareAttributes(entry.getAttributes());
            rslt.setAttributes(attributes);
        }
        if (!entry.getActions().isEmpty()) {  // Actions
            List<NotificationAction> actions = prepareActions(entry.getActions(),
                    username);
            rslt.setAvailableActions(actions);
        }

        return rslt;

    }
private NotificationEntry prepareEntry(JpaEntry entry, String username) {

        /*
         * Implementation Note:  Most notification fields are optional.  This
         * method impl avoids setting fields within the NotificationEntry when
         * those fields are (essentially) unspecified on the JpaEntry in order
         * not to run afoul of any logic (present or future) that may trigger
         * when a field is set (e.g. validation, virtual members, change
         * tracking).
         */

        NotificationEntry rslt = new NotificationEntry();

        // Id & title will always be present
        rslt.setId(ID_PREFIX + entry.getId());
        final String title = entry.getTitle();
        if (StringUtils.isBlank(title)) {
            log.warn("User '" + username + "' had a notification with an empty title:  " + entry.toString());
            return null;
        }
        rslt.setTitle(title);

        // But these fields are optional
        if (!StringUtils.isBlank(entry.getBody())) {  // Body
            rslt.setBody(entry.getBody());
        }
        if (entry.getDueDate() != null) {  // Due date
            rslt.setDueDate(entry.getDueDate());
        }
        if (!StringUtils.isBlank(entry.getImage())) {  // Image
            rslt.setImage(entry.getImage());
        }
        if (!StringUtils.isBlank(entry.getLinkText())) {  // Link text
            rslt.setLinkText(entry.getLinkText());
        }
        if (entry.getPriority() != 0) {  // Priority
            rslt.setPriority(entry.getPriority());
        }
        if (!StringUtils.isBlank(entry.getSource())) {  // Source
            rslt.setSource(entry.getSource());
        }
        if (!StringUtils.isBlank(entry.getUrl())) {  // Url
            rslt.setUrl(entry.getUrl());
        }

        // States (transaction log)
        Map<NotificationState,Date> states = prepareStates(entry, username);
        rslt.setStates(states);

        // Collections of items...
        if (!entry.getAttributes().isEmpty()) {  // Attributes
            List<NotificationAttribute> attributes = prepareAttributes(entry.getAttributes());
            rslt.setAttributes(attributes);
        }
        if (!entry.getActions().isEmpty()) {  // Actions
            List<NotificationAction> actions = prepareActions(entry.getActions(),
                    username);
            rslt.setAvailableActions(actions);
        }

        return rslt;

    }
private NotificationEntry prepareEntry ( JpaEntry entry , String username ) { /*
         * Implementation Note:  Most notification fields are optional.  This
         * method impl avoids setting fields within the NotificationEntry when
         * those fields are (essentially) unspecified on the JpaEntry in order
         * not to run afoul of any logic (present or future) that may trigger
         * when a field is set (e.g. validation, virtual members, change
         * tracking).
         */ NotificationEntry rslt = new NotificationEntry ( ) ; // Id & title will always be present rslt . setId ( ID_PREFIX + entry . getId ( ) ) ; final String title = entry . getTitle ( ) ; if ( StringUtils . isBlank ( title ) ) { log . warn ( "User '" + username + "' had a notification with an empty title:  " + entry . toString ( ) ) ; return null ; } rslt . setTitle ( title ) ; // But these fields are optional if ( ! StringUtils . isBlank ( entry . getBody ( ) ) ) { // Body rslt . setBody ( entry . getBody ( ) ) ; } if ( entry . getDueDate ( ) != null ) { // Due date rslt . setDueDate ( entry . getDueDate ( ) ) ; } if ( ! StringUtils . isBlank ( entry . getImage ( ) ) ) { // Image rslt . setImage ( entry . getImage ( ) ) ; } if ( ! StringUtils . isBlank ( entry . getLinkText ( ) ) ) { // Link text rslt . setLinkText ( entry . getLinkText ( ) ) ; } if ( entry . getPriority ( ) != 0 ) { // Priority rslt . setPriority ( entry . getPriority ( ) ) ; } if ( ! StringUtils . isBlank ( entry . getSource ( ) ) ) { // Source rslt . setSource ( entry . getSource ( ) ) ; } if ( ! StringUtils . isBlank ( entry . getUrl ( ) ) ) { // Url rslt . setUrl ( entry . getUrl ( ) ) ; } // States (transaction log) Map < NotificationState , Date > states = prepareStates ( entry , username ) ; rslt . setStates ( states ) ; // Collections of items... if ( ! entry . getAttributes ( ) . isEmpty ( ) ) { // Attributes List < NotificationAttribute > attributes = prepareAttributes ( entry . getAttributes ( ) ) ; rslt . setAttributes ( attributes ) ; } if ( ! entry . getActions ( ) . isEmpty ( ) ) { // Actions List < NotificationAction > actions = prepareActions ( entry . getActions ( ) , username ) ; rslt . setAvailableActions ( actions ) ; } return rslt ; }
Creates a {@link NotificationEntry} from a {@link JpaEntry}, but will
return null if that process cannot be performed in a valid way.

@return A fully-constituted {@link NotificationEntry} or null
Creates a { @link NotificationEntry } from a { @link JpaEntry } but will return null if that process cannot be performed in a valid way .