Coverage Report - org.openpermis.editor.policy.presenter.DomainPresenter
 
Classes in this File Line Coverage Branch Coverage Complexity
DomainPresenter
0%
0/18
0%
0/2
1.5
 
 1  
 /*
 2  
  * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport
 3  
  *                     (http://www.vbs.admin.ch)
 4  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 5  
  * All rights reserved.
 6  
  *
 7  
  * Licensed under the Open Permis License which accompanies this distribution,
 8  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 9  
  */
 10  
 package org.openpermis.editor.policy.presenter;
 11  
 
 12  
 import java.net.URI;
 13  
 
 14  
 import org.slf4j.Logger;
 15  
 import org.slf4j.LoggerFactory;
 16  
 
 17  
 import org.openpermis.editor.policy.beans.PropertyChange;
 18  
 import org.openpermis.policy.bean.DomainBean;
 19  
 
 20  
 /**
 21  
  * Presenter for a single resource {@link DomainBean}.
 22  
  * @since 0.1.0
 23  
  */
 24  
 public class DomainPresenter
 25  
         extends PartPresenter<DomainBean>
 26  
 {
 27  
 
 28  
         //---- Static
 29  
 
 30  
         /**
 31  
          * The logger object of this class.
 32  
          * @since 0.1.0
 33  
          */
 34  0
         private static final Logger LOGGER =
 35  
                 LoggerFactory.getLogger(DomainPresenter.class);
 36  
 
 37  
         //---- State
 38  
 
 39  
         /**
 40  
          * The identity of the resource domain.
 41  
          * @since 0.1.0
 42  
          */
 43  
         private URI identity;
 44  
 
 45  
         //---- Constructors
 46  
 
 47  
         /**
 48  
          * Creates a new resource domain presenter.
 49  
          * @param model the resource domain rule to work on, must not be {@code null}.
 50  
          * @param context policy context that provides additional information.
 51  
          * @since 0.1.0
 52  
          */
 53  
         public DomainPresenter (DomainBean model, PolicyContext context) {
 54  0
                 super(model, context);
 55  0
                 updateIdentity();
 56  0
         }
 57  
 
 58  
         //---- Methods
 59  
 
 60  
         /**
 61  
          * Returns the identity of the model resource domain.
 62  
          * @return the identity of the model resource domain.
 63  
          * @since 0.1.0
 64  
          */
 65  
         public URI getIdentity () {
 66  0
                 return this.identity;
 67  
         }
 68  
 
 69  
         /**
 70  
          * Sets the identity of the model resource domain.
 71  
          * @param identity the new identity to set.
 72  
          * @since 0.1.0
 73  
          */
 74  
         public void setIdentity (URI identity) {
 75  
                 try {
 76  0
                         final URI oldIdentity = getIdentity();
 77  0
                         this.identity = identity;
 78  0
                         firePropertyChange("identity", oldIdentity, this.identity);
 79  0
                         change("identity", this.identity);
 80  0
                 } catch (final Exception e) {
 81  0
                         LOGGER.warn("Cannot set target domain [" + identity + "].", e);
 82  0
                 }
 83  0
         }
 84  
 
 85  
         //---- PropertyChange
 86  
 
 87  
         /**
 88  
          * Handles property changes of identity.
 89  
          * @since 0.1.0
 90  
          */
 91  
         @PropertyChange(bean = DomainBean.class, property = "identity")
 92  
         public void updateIdentity () {
 93  0
                 final URI oldIdentity = this.identity;
 94  0
                 this.identity = getModel().getIdentity();
 95  0
                 firePropertyChange("identity", oldIdentity, this.identity);
 96  0
                 setTitleParameters(this.identity == null ? "" : this.identity.toString());
 97  0
         }
 98  
 
 99  
 }