/**
   * Creates an {@link AttachedDevice} resource in the DataBase and validates the transaction
   *
   * @param resource - The {@link AttachedDevice} resource to create
   */
  public void create(AttachedDevice resource) {
    // Store the created resource
    DB.store(resource);
    // MgmtObjs
    MgmtObjs mgmtObjs = new MgmtObjs();
    mgmtObjs.setUri(resource.getMgmtObjsReference());
    mgmtObjs.setCreationTime(resource.getCreationTime());
    mgmtObjs.setLastModifiedTime(resource.getLastModifiedTime());
    mgmtObjs.setAccessRightID(resource.getAccessRightID());
    DAOFactory.getMgmtObjsDAO().create(mgmtObjs);
    // Subscriptions
    Subscriptions subscriptions = new Subscriptions();
    subscriptions.setUri(resource.getSubscriptionsReference());
    DAOFactory.getSubscriptionsDAO().create(subscriptions);
    // Create the query based on the uri constraint
    Query query = DB.query();
    query.constrain(AttachedDevices.class);
    query.descend("uri").constrain(resource.getUri().split("/" + resource.getId())[0]);
    // Store all the founded resources
    ObjectSet<AttachedDevices> result = query.execute();

    // Update the lastModifiedTime attribute of the parent
    AttachedDevices attachedDevices = result.get(0);
    // Update the lastModifiedTime attribute of the parent
    attachedDevices.setLastModifiedTime(
        DateConverter.toXMLGregorianCalendar(new Date()).toString());
    DB.store(attachedDevices);
    // Validate the current transaction
    commit();
  }
  /**
   * Updates an existing {@link AttachedDevice} resource in the DataBase
   *
   * @param resource - The {@link AttachedDevice} the updated resource
   */
  public void update(AttachedDevice resource) {
    // Store the updated resource
    DB.store(resource);
    // Create the query based on the uri constraint
    Query query = DB.query();
    query.constrain(AttachedDevices.class);
    query.descend("uri").constrain(resource.getUri().split("/" + resource.getId())[0]);
    // Store all the founded resources
    ObjectSet<AttachedDevices> result = query.execute();

    // Update the lastModifiedTime attribute of the parent
    AttachedDevices attachedDevices = result.get(0);
    // Update the lastModifiedTime attribute of the parent
    attachedDevices.setLastModifiedTime(
        DateConverter.toXMLGregorianCalendar(new Date()).toString());
    DB.store(attachedDevices);
    // Validate the current transaction
    commit();
  }
  /**
   * Deletes the {@link AttachedDevice} resource from the DataBase without validating the
   * transaction
   *
   * @param resource - The {@link AttachedDevice} resource to delete
   */
  public void lazyDelete(AttachedDevice resource) {
    // delete subscriptions
    DAOFactory.getSubscriptionsDAO()
        .lazyDelete(
            DAOFactory.getSubscriptionsDAO().lazyFind(resource.getSubscriptionsReference()));
    // delete mgmtObjs
    DAOFactory.getMgmtObjsDAO()
        .lazyDelete(DAOFactory.getMgmtObjsDAO().lazyFind(resource.getMgmtObjsReference()));
    // Create the query based on the uri constraint
    Query query = DB.query();
    query.constrain(AttachedDevices.class);
    query.descend("uri").constrain(resource.getUri().split("/" + resource.getId())[0]);
    // Store all the founded resources
    ObjectSet<AttachedDevices> result = query.execute();

    // Update the lastModifiedTime attribute of the parent
    AttachedDevices attachedDevices = result.get(0);
    // Update the lastModifiedTime attribute of the parent
    attachedDevices.setLastModifiedTime(
        DateConverter.toXMLGregorianCalendar(new Date()).toString());
    DB.store(attachedDevices);
  }