private MarshalledValue<E, C> marshalEntry(E value) {
   try {
     return this.valueFactory.createMarshalledValue(value);
   } catch (IOException e) {
     throw InfinispanEjbMessages.MESSAGES.serializationFailure(e, value.getId());
   }
 }
Exemplo n.º 2
0
 /**
  * Called by the base class to add attributes to the meta data.
  *
  * @param metaData the meta data instance receiving the attributes.
  * @param ebXML the ebXML instance containing the attributes.
  */
 protected void addAttributesFromEbXML(C metaData, E ebXML) {
   metaData.setComments(ebXML.getDescription());
   metaData.setTitle(ebXML.getName());
   metaData.setEntryUuid(ebXML.getId());
   metaData.setLogicalUuid(ebXML.getLid());
   metaData.setVersion(ebXML.getVersionInfo());
 }
  /**
   * Creates an entity
   *
   * @param entity The entity to create in db
   * @return The newly created entity
   */
  public E create(E entity) {
    if (entity.getId() != null) {
      throw new BadRequestException(ID_ON_POST);
    }

    return repository.save(entity);
  }
  /** Test get entity. */
  @Test
  public void testGetEntity() {
    // get a Entity
    E retrievedEntity = getEntity(getEntityUrl(), getEntity().getId(), getClazz());

    // test that our get worked
    assertEquals(retrievedEntity.getId(), getEntity().getId());
  }
Exemplo n.º 5
0
 @Override
 public R toResource(E entity) {
   // will add also a link with rel self pointing itself
   R resource = createResourceWithId(entity.getId(), entity);
   // adding a link with rel books pointing to the author's books
   // resource.add(linkTo(methodOn(AuthorController.class).getAuthorBooks(author.getAuthorId())).withRel("books"));
   return resource;
 }
Exemplo n.º 6
0
 public static <E extends BusinessEntity<I>, I extends Serializable> List<I> getIds(
     List<E> entities) {
   List<I> ids = new ArrayList<>(entities.size());
   for (E entity : entities) {
     ids.add(entity.getId());
   }
   return ids;
 }
 private <E extends AbstractEntity> void fillActionableItem(E entity) {
   if (entity != null) {
     actionableItemId = entity.getId();
     actionableItemClass = entity.getClass().getCanonicalName();
     if (Namable.class.isAssignableFrom(entity.getClass())) {
       actionableItemName = ((Namable) entity).getUniqueName();
     } else {
       actionableItemName = String.valueOf(entity);
     }
   }
 }
  public <E extends InstituicaoNotificadora>
      List<QualificacaoRecusaFamiliar> relatorioQualificacaoRecusa(
          Calendar datIni, Calendar datFim, Collection<E> hospitais) {
    final List<Long> ids = new ArrayList<>();

    for (E hospital : hospitais) {
      ids.add(hospital.getId());
    }

    return processoNotificacaoRepository.getRelatorioQualificacaoRecusaFamiliar(
        datIni, datFim, ids);
  }
Exemplo n.º 9
0
 @Override
 public boolean add(E rule) {
   if (rule == null) {
     return false;
   }
   final int index = rule.getId() - 1;
   boolean alreadyThere = hasOneAt(matrix, index);
   if (!alreadyThere) {
     setUnSet(matrix, index, true);
     size++;
   }
   return !alreadyThere;
 }
  /** Test put entity. */
  @Test
  public void testPutEntity() {
    Map<String, String> uriVariables = new HashMap<String, String>();
    uriVariables.put("id", String.valueOf(getEntity().getId()));

    // call the update for the RESTful API
    HttpStatus status = putEntity(putEntityUrl(), uriVariables, getEntity());
    assertEquals(status.toString(), "204");

    // double-check the Entity info was updated by re-pulling the Entity
    E retrievedEntity = getEntity(getEntityUrl(), getEntity().getId(), getClazz());
    assertEquals(retrievedEntity.getId(), getEntity().getId());
  }
Exemplo n.º 11
0
    @Override
    public boolean isAccessible(E resrep) {
      boolean ret = false;
      URI id = resrep.getId();

      ApprovalRequest obj = _permissionsHelper.getObjectById(id, ApprovalRequest.class);
      if (obj == null) {
        return false;
      }
      if (obj.getTenant().toString().equals(_user.getTenantId())) {
        return true;
      }
      ret = isTenantAccessible(uri(obj.getTenant()));
      return ret;
    }
    @Override
    public boolean isAccessible(E resrep) {
      boolean ret = false;
      URI id = resrep.getId();

      Vcenter obj = _permissionsHelper.getObjectById(id, Vcenter.class);
      if (obj == null) {
        return false;
      }
      if (obj.getTenant().toString().equals(_user.getTenantId())
          || isSystemAdmin()
          || isSecurityAdmin()) {
        return true;
      }
      ret = isTenantAccessible(obj.getTenant());
      return ret;
    }
Exemplo n.º 13
0
 // 保存
 public String save() throws Exception {
   JSONObject json = new JSONObject();
   try {
     this.beforeSave(e);
     this.getCrudService().save(e);
     this.afterSave(e);
     json.put("success", true);
     json.put("id", e.getId());
     json.put("msg", getText("form.save.success"));
   } catch (Exception e1) {
     logger.warn(e1.getMessage(), e1);
     json.put("success", false);
     json.put("msg", getSaveExceptionMsg(e1));
     json.put("e", e.getClass().getSimpleName());
   }
   this.json = json.toString();
   return "json";
 }
 @Override
 public void update(E entry, boolean modified) {
   final K id = entry.getId();
   this.trace("update(%s, %s)", id, modified);
   try {
     if (modified) {
       final MarshalledValue<E, C> value = this.marshalEntry(entry);
       Operation<Void> operation =
           new Operation<Void>() {
             @Override
             public Void invoke(Cache<K, MarshalledValue<E, C>> cache) {
               cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).put(id, value);
               return null;
             }
           };
       this.invoke(operation);
     }
   } finally {
     this.releaseSessionOwnership(id, false);
   }
 }
Exemplo n.º 15
0
 @Override
 public boolean containsAll(Collection<?> c) {
   if (c instanceof MatrixSet) {
     for (int i = 0; i < matrix.length; i++) {
       long l = matrix[i] | ((MatrixSet) c).matrix[i];
       if (Long.bitCount(l) > Long.bitCount(matrix[i])) {
         return false;
       }
     }
   } else {
     for (E rule : (Collection<? extends E>) c) {
       if (rule == null) {
         return false;
       }
       if (!hasOneAt(matrix, rule.getId() - 1)) {
         return false;
       }
     }
   }
   return true;
 }
  @Override
  public Set<K> insert(E entry) {
    final K id = entry.getId();
    this.trace("insert(%s)", id);

    this.acquireSessionOwnership(id, true);
    try {
      final MarshalledValue<E, C> value = this.marshalEntry(entry);
      Operation<Void> operation =
          new Operation<Void>() {
            @Override
            public Void invoke(Cache<K, MarshalledValue<E, C>> cache) {
              cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).put(id, value);
              return null;
            }
          };
      this.invoke(operation);
    } finally {
      this.releaseSessionOwnership(id, false);
    }
    return Collections.emptySet();
  }
Exemplo n.º 17
0
  @Override
  public int compareTo(E that) {
    if (that == null) throw new NullPointerException("You cannot compare with null");

    if (this.equals(that)) return 0;

    String thisId = this.getId();
    String thatId = that.getId();

    if (thisId == null) return -1;
    if (thatId == null) return +1;

    int ret = NaturalOrderComparator.get().compare(thisId, thatId);

    // The id's may be the same if these are objects from different collections
    // We avoid zero in an ugly way like this.
    // TODO: Improve by comparing collections and then databases.
    if (ret == 0) {
      ret = -1;
    }

    return ret;
  }
 /**
  * Deletes an entity
  *
  * @param entity to be updated. Must include db ID.
  */
 public void update(E entity) {
   if (repository.findOne(entity.getId()) == null) {
     throw new ResourceNotFoundException(String.format(NOT_FOUND, entity.getId()));
   }
   repository.save(entity);
 }
Exemplo n.º 19
0
 @Override
 @Transactional(readOnly = false, propagation = Propagation.MANDATORY)
 public void supprimer(E entite) {
   E entiteASupprimer = entityManager.getReference(classeEntite, entite.getId());
   entityManager.remove(entiteASupprimer);
 }
Exemplo n.º 20
0
 @Override
 public final boolean addEdge(final E e, final V v1, final V v2, final EdgeType edgeType) {
   edgemaps.put(e.getId(), e);
   return graph.addEdge(e, v1, v2, edu.uci.ics.jung.graph.util.EdgeType.DIRECTED);
 }
Exemplo n.º 21
0
 @Override
 public final boolean addEdge(final E e, final V v1, final V v2) {
   edgemaps.put(e.getId(), e);
   return graph.addEdge(e, v1, v2);
 }