/**
  * Convenience method that safely checks whether the value of a given propertytype is equal to a
  * given value.
  *
  * <p>The method assumes that the property is single-valued.
  *
  * <p>The method safely handles the fact that a property might not exist at all. In this case the
  * result is always <code>false</code>
  *
  * <p>The given value shall not be <code>null</code>, otherwise a {@link NullPointerException} is
  * thrown.
  *
  * <p>The expected value is compared to the so called raw value of the property. In the Hitro UI
  * configuration this is what is provided by the "id" attribute of an <em>option</em> element.
  *
  * @param expected
  */
 private boolean isRawPropertyValueEqual(String propertyType, String expected) {
   Property p = entity.getProperties(propertyType).getProperty(0);
   if (p != null) {
     return expected.equals(p.getPropertyValue());
   }
   return false;
 }
  private void setLinkText() {
    PropertyList propList = entity.getProperties(type.getId());
    savedProp = propList != null ? propList.getProperty(0) : null;

    if (savedProp == null) {
      savedProp = entity.createNewProperty(type, ""); // $NON-NLS-1$
    }
    if (savedProp.getPropertyValue() != null) {
      link.setText(savedProp.getPropertyValue());
    }
    link.pack();
  }
 protected String getHref() {
   Matcher matcher = pattern.matcher(savedProp.getPropertyValue());
   if (matcher.find()) {
     return matcher.group(1);
   }
   return ""; //$NON-NLS-1$
 }
  /**
   * Returns a set of roles the person to which this configuration belongs is in.
   *
   * <p>The roles returned herein are to be used for checking whether the user has access to
   * elements of the {@link BSIModel}.
   *
   * <p>In contrast the roles of the type {@link Person} are only meant for the IT security model.
   *
   * @return
   */
  public Set<String> getRoles(boolean withUserRole) {
    List<Property> properties = entity.getProperties(Configuration.PROP_ROLES).getProperties();

    Set<String> roles = null;

    if (properties != null) {
      roles = new HashSet<String>(properties.size());
      for (Property p : properties) {
        roles.add(p.getPropertyValue());
      }
    } else {
      roles = new HashSet<String>();
    }
    if (withUserRole) {
      roles.add(getUser());
    }
    return roles;
  }
  public static void hydrateEntity(IBaseDao dao, Entity entity) {
    if (dao == null) {
      Logger.getLogger(HydratorUtil.class).error("Missing DAO, cannot hydrate.");
      return;
    }
    if (entity == null) return;

    Map<String, PropertyList> lists = entity.getTypedPropertyLists();
    Set<Entry<String, PropertyList>> entrySet = lists.entrySet();
    for (Entry<String, PropertyList> entry : entrySet) {
      PropertyList list = entry.getValue();
      List<Property> propertyList = list.getProperties();
      dao.initialize(propertyList);
      // set the parent in the property since it is not mapped by hibernate anymore
      for (Property property : propertyList) {
        property.setParent(entity);
      }
    }
  }
 public void update() {
   PropertyList propList = entity.getProperties(type.getId());
   Property entityProp;
   entityProp = propList != null ? propList.getProperty(0) : null;
   if (entityProp != null && !link.getText().equals(entityProp.getPropertyValue())) {
     savedProp = entityProp;
     if (Display.getCurrent() != null) {
       setLinkText();
     } else {
       Display.getDefault()
           .asyncExec(
               new Runnable() {
                 public void run() {
                   setLinkText();
                 }
               });
     }
   }
 }
 protected void showLinkEditDialog() {
   String href = ""; // $NON-NLS-1$
   String name = ""; // $NON-NLS-1$
   if (savedProp != null && savedProp.getPropertyValue() != null) {
     Matcher matcher = pattern.matcher(savedProp.getPropertyValue());
     if (matcher.find()) {
       href = matcher.group(1);
       name = matcher.group(2);
     }
   }
   URLControlDialog dialog =
       new URLControlDialog(Display.getCurrent().getActiveShell(), name, href, this.type);
   if (dialog.open() == InputDialog.OK) {
     savedProp.setPropertyValue(
         "<a href=\""
             + dialog.getHref()
             + "\">" //$NON-NLS-1$ //$NON-NLS-2$
             + dialog.getName()
             + "</a>"); //$NON-NLS-1$
     update();
   }
 }
 public static boolean isVertraulichkeitBegruendung(Property prop) {
   return prop.getPropertyTypeID().indexOf(VERTRAULICHKEIT_BEGRUENDUNG) != -1;
 }
 public static boolean isVerfuegbarkeitBegruendung(Property prop) {
   return prop.getPropertyTypeID().indexOf(VERFUEGBARKEIT_BEGRUENDUNG) != -1;
 }
 public static boolean isIntegritaet(Property prop) {
   return pat_integritaet.matcher(prop.getPropertyTypeID()).matches();
 }
 public static boolean isVertraulichkeit(Property prop) {
   return pat_vertraulichkeit.matcher(prop.getPropertyTypeID()).matches();
 }
 public static boolean isIntegritaetBegruendung(Property prop) {
   return prop.getPropertyTypeID().indexOf(INTEGRITAET_BEGRUENDUNG) != -1;
 }