Exemplo n.º 1
0
  public List<? extends ResultType> checkCache(KeyType key) throws NotCachedException {
    List<EntityType> oldItems = mapper.queryExisting(key);

    if (oldItems.isEmpty()) throw new NotCachedException();

    long now = System.currentTimeMillis();
    boolean outdated = false;
    boolean haveNoResultsMarker = false;
    for (EntityType d : oldItems) {
      if ((d.getLastUpdated().getTime() + getExpirationTime()) < now) {
        outdated = true;
      }
      if (d.isNoResultsMarker()) {
        haveNoResultsMarker = true;
      }
    }

    if (outdated) {
      logger.debug("Cache appears outdated for key {}", key);
      throw new ExpiredCacheException();
    }

    if (haveNoResultsMarker) {
      logger.debug("Negative result cached for key {}", key);
      return Collections.emptyList();
    }

    sort(oldItems);
    return formResultTypeList(oldItems);
  }
  private void introspectSecondaryTable(EntityType entityType, Class type) {
    getInternalSecondaryTableConfig(type, _annotationCfg);
    SecondaryTable secondaryTableAnn = (SecondaryTable) _annotationCfg.getAnnotation();
    SecondaryTableConfig secondaryTableConfig = _annotationCfg.getSecondaryTableConfig();

    AmberTable secondaryTable = null;

    if ((secondaryTableAnn != null) || (secondaryTableConfig != null)) {
      String secondaryName;

      if (secondaryTableAnn != null) secondaryName = secondaryTableAnn.name();
      else secondaryName = secondaryTableConfig.getName();

      secondaryTable = _persistenceUnit.createTable(secondaryName);

      entityType.addSecondaryTable(secondaryTable);

      // XXX: pk
    }

    if (secondaryTableAnn != null) {
      PrimaryKeyJoinColumn[] joinAnn = secondaryTableAnn.pkJoinColumns();

      linkSecondaryTable(entityType.getTable(), secondaryTable, joinAnn);
    }
  }
Exemplo n.º 3
0
  private void addCollection(AmberType targetType) {
    ElementCollectionField eltCollectionField;

    eltCollectionField = new ElementCollectionField(_sourceType, _fieldName);
    eltCollectionField.setType(targetType);
    eltCollectionField.setLazy(isFetchLazy());

    CollectionTableConfig collectionTableConfig = _collectionTable;

    AmberPersistenceUnit persistenceUnit = _sourceType.getPersistenceUnit();

    String sqlTable = collectionTableConfig.getName();
    AmberTable mapTable = persistenceUnit.createTable(sqlTable);

    HashMap<String, JoinColumnConfig> joinColumnsConfig = collectionTableConfig.getJoinColumnMap();

    ArrayList<ForeignColumn> sourceColumns = null;

    sourceColumns =
        calculateColumns(
            _field,
            _fieldName,
            mapTable,
            _sourceType.getTable().getName() + "_",
            _sourceType,
            joinColumnsConfig);

    eltCollectionField.setAssociationTable(mapTable);
    eltCollectionField.setTable(sqlTable);

    eltCollectionField.setSourceLink(
        new LinkColumns(mapTable, _sourceType.getTable(), sourceColumns));

    _sourceType.addField(eltCollectionField);
  }
Exemplo n.º 4
0
 void addWidgets() {
   widget(
       "EntityTypeList",
       WidgetType.EntityTypeSet,
       new PortRest("entity_type_item", EntityType.name()));
   widget("EntityTypeItem", EntityType, new PortRest("entity_type_page", EntityType.name()));
   widget("EntityTitle", EntityType);
 }
  private void introspectTableCache(EntityType entityType, Class type) {
    AmberTableCache tableCache = (AmberTableCache) type.getAnnotation(AmberTableCache.class);

    if (tableCache != null) {
      entityType.getTable().setReadOnly(tableCache.readOnly());

      long cacheTimeout = Period.toPeriod(tableCache.timeout());
      entityType.getTable().setCacheTimeout(cacheTimeout);
    }
  }
  private void serialize(Serializer serializer, Collection<EntityType> models) {
    for (EntityType model : models) {
      try {
        Type type = conf.getTypeMappings().getPathType(model, model, true);
        String packageName = type.getPackageName();
        String className =
            !packageName.isEmpty()
                ? (packageName + "." + type.getSimpleName())
                : type.getSimpleName();

        // skip if type is excluded class or in excluded package
        if (conf.isExcludedPackage(model.getPackageName())
            || conf.isExcludedClass(model.getFullName())) {
          continue;
        }

        Set<TypeElement> elements = context.typeElements.get(model.getFullName());

        if (elements == null) {
          elements = new HashSet<TypeElement>();
        }
        for (Property property : model.getProperties()) {
          if (property.getType().getCategory() == TypeCategory.CUSTOM) {
            Set<TypeElement> customElements =
                context.typeElements.get(property.getType().getFullName());
            if (customElements != null) {
              elements.addAll(customElements);
            }
          }
        }

        processingEnv
            .getMessager()
            .printMessage(Kind.NOTE, "Generating " + className + " for " + elements);
        JavaFileObject fileObject =
            processingEnv
                .getFiler()
                .createSourceFile(className, elements.toArray(new Element[elements.size()]));
        Writer writer = fileObject.openWriter();
        try {
          SerializerConfig serializerConfig = conf.getSerializerConfig(model);
          serializer.serialize(model, serializerConfig, new JavaWriter(writer));
        } finally {
          if (writer != null) {
            writer.close();
          }
        }

      } catch (IOException e) {
        System.err.println(e.getMessage());
        processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage());
      }
    }
  }
 private void processProjectionTypes(Set<TypeElement> elements) {
   Set<Element> visited = new HashSet<Element>();
   for (Element element : getElements(QueryProjection.class)) {
     Element parent = element.getEnclosingElement();
     if (!elements.contains(parent) && !visited.contains(parent)) {
       EntityType model = elementHandler.handleProjectionType((TypeElement) parent);
       registerTypeElement(model.getFullName(), (TypeElement) parent);
       context.projectionTypes.put(model.getFullName(), model);
       visited.add(parent);
     }
   }
 }
 private void addSupertypeFields(EntityType model, Set<EntityType> handled) {
   if (handled.add(model)) {
     for (Supertype supertype : model.getSuperTypes()) {
       EntityType entityType = context.allTypes.get(supertype.getType().getFullName());
       if (entityType != null) {
         addSupertypeFields(entityType, handled);
         supertype.setEntityType(entityType);
         model.include(supertype);
       }
     }
   }
 }
  private EntityType introspectEntityType(Class type, EntityType parentType) throws SQLException {
    getInternalEntityConfig(type, _annotationCfg);

    Entity entityAnn = (Entity) _annotationCfg.getAnnotation();
    EntityConfig entityConfig = _annotationCfg.getEntityConfig();

    boolean isEntity = !_annotationCfg.isNull();

    if (!isEntity) return null;

    EntityType entityType;
    String typeName;

    if (entityConfig != null) typeName = entityConfig.getClassName();
    else typeName = entityAnn.name();

    // Validates the type
    String entityName;
    Inheritance inheritanceAnn = null;
    InheritanceConfig inheritanceConfig = null;
    Class rootClass = type;
    Entity rootEntityAnn = null;
    EntityConfig rootEntityConfig = null;

    validateType(type, true);

    // jpa/0ge2
    // if (hasInheritance) {

    if (entityConfig == null) entityName = entityAnn.name();
    else {
      entityName = entityConfig.getClassName();

      int p = entityName.lastIndexOf('.');

      if (p > 0) entityName = entityName.substring(p + 1);
    }

    if ((entityName == null) || "".equals(entityName)) {
      entityName = type.getSimpleName();
    }

    entityType = _persistenceUnit.createEntity(entityName, type);

    _configManager.addType(type, new EntityConfig(type.getName(), this, entityType));

    boolean isField = isField(type, entityConfig, false);

    if (isField) entityType.setFieldAccess(true);

    return entityType;
  }
Exemplo n.º 10
0
  public void process(RelationContainer container) {
    for (RelationMember member : container.getEntity().getMembers()) {
      EntityType memberType = member.getMemberType();

      if (memberType.equals(EntityType.Way)) {
        requiredWays.set(member.getMemberId());
      } else if (memberType.equals(EntityType.Node)) {
        requiredNodes.set(member.getMemberId());
      }
    }

    allRelations.add(container);
  }
 @Override
 void addWidgets() {
   widget("EntityTypeList", EntityTypeSet, new PortRest("entity_type_item", EntityType.name()));
   widget("EntityTypeItem", EntityType, new PortRest("entity_type_page", EntityType.name()));
   widget("EntityTitle2", EntityType, new PortRest("entity_list", EntityType.name()));
   widget("EntityOrderedList", EntityType, new PortRest("entity_item", Entity.name()));
   widget("EntityItem2", Entity, new PortRest("property_value", Property.name()));
   widget("SimpleValue", Property);
   widget("SimpleValue2", Property);
   widget("SimpleValue3", Property);
   widget("SimpleValue4", Property);
   widget("SimpleValue5", Property);
 }
Exemplo n.º 12
0
 @Override
 void addWidgets() {
   widget("EntityTypeList", EntityTypeSet, new PortRest("entity_type_item", EntityType.name()));
   widget("EntityTypeItem", EntityType, new PortRest("entity_type_page", EntityType.name()));
   widget(
       "ListingTable",
       EntityType,
       new PortRest("table_head", PropertyType.name()),
       new PortRest("table_line", Entity.name()));
   widget("TableHead", PropertyType);
   widget("TableLine", Entity, new PortRest("line_cell", Property.name()));
   widget("TableCell", Property);
 }
Exemplo n.º 13
0
  public static void checkEntityType(EntityType<?> entity) {
    // Check required fields
    assertNotNull(entity.getName(), String.format(NOT_NULL_OBJECT_FMT, "Name", "EntityType"));

    // Check optional fields
    // NOTE description cannot be checked
    Set<Task> tasks = entity.getTasks();
    if (tasks != null && tasks != null && !tasks.isEmpty()) {
      for (Task task : tasks) checkTask(task);
    }

    // Check parent type
    checkResourceType(entity);
  }
Exemplo n.º 14
0
 private EntityType createEntityType(Class<?> cl, Map<String, EntityType> types) {
   if (types.containsKey(cl.getName())) {
     return types.get(cl.getName());
   } else {
     EntityType type = new EntityType(new ClassType(TypeCategory.ENTITY, cl));
     typeMappings.register(type, queryTypeFactory.create(type));
     if (!cl.getSuperclass().equals(Object.class)) {
       type.addSupertype(new Supertype(new ClassType(cl.getSuperclass())));
     }
     types.put(cl.getName(), type);
     allTypes.put(cl.getName(), type);
     return type;
   }
 }
  private void PushChanges() throws Exception {
    BookmarkCollection updates = Bookmark.GetBookmarksForServerUpdate(getContextSource());
    BookmarkCollection deletes = Bookmark.GetBookmarksForServerDelete(this.getContextSource());
    if (updates.size() == 0 && deletes.size() == 0) return;

    // et...
    EntityType et = EntityType.GetEntityType(Bookmark.class);

    // get the server ones...
    BookmarksService service = new BookmarksService();
    BookmarkCollection fromServer = service.GetAll();

    // walk the locally updated items…
    for (Bookmark local : updates) {
      // find it in our server set...
      Bookmark toUpdate = null;
      for (Bookmark server : fromServer) {
        if (local.getOrdinal() == server.getOrdinal()) {
          toUpdate = server;
          break;
        }
      }

      // did we have one to change?
      if (toUpdate != null) {
        // walk the fields...
        int serverId = 0;
        for (EntityField field : et.getFields()) {
          if (!(field.getIsKey()))
            toUpdate.SetValue(field, local.GetValue(field), SetReason.UserSet);
          else serverId = toUpdate.getBookmarkId();
        }

        // send that up...
        service.PushUpdate(this.getContextSource(), toUpdate, serverId);
      } else {
        // we need to insert it...
        service.PushInsert(this.getContextSource(), local);
      }
    }

    // what about ones to delete?
    for (Bookmark local : deletes) {
      // find a matching ordinal on the server...
      for (Bookmark server : fromServer) {
        if (local.getOrdinal() == server.getOrdinal())
          service.PushDelete(this.getContextSource(), server, server.getBookmarkId());
      }
    }
  }
Exemplo n.º 16
0
  public void unmarshal(DataInputStream dis) {
    super.unmarshal(dis);

    try {
      minefieldID.unmarshal(dis);
      requestingEntityID.unmarshal(dis);
      minefieldSequenceNumbeer = (int) dis.readUnsignedShort();
      requestID = (short) dis.readUnsignedByte();
      pduSequenceNumber = (short) dis.readUnsignedByte();
      numberOfPdus = (short) dis.readUnsignedByte();
      numberOfMinesInThisPdu = (short) dis.readUnsignedByte();
      numberOfSensorTypes = (short) dis.readUnsignedByte();
      pad2 = (short) dis.readUnsignedByte();
      dataFilter = dis.readInt();
      mineType.unmarshal(dis);
      for (int idx = 0; idx < numberOfSensorTypes; idx++) {
        TwoByteChunk anX = new TwoByteChunk();
        anX.unmarshal(dis);
        sensorTypes.add(anX);
      }

      pad3 = (short) dis.readUnsignedByte();
      for (int idx = 0; idx < numberOfMinesInThisPdu; idx++) {
        Vector3Float anX = new Vector3Float();
        anX.unmarshal(dis);
        mineLocation.add(anX);
      }

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of unmarshal method
Exemplo n.º 17
0
  @Override
  public void complete() {
    AmberPersistenceUnit persistenceUnit = _sourceType.getPersistenceUnit();

    Class targetClass = getTargetClass();

    if (targetClass == null || void.class.equals(targetClass))
      throw error(
          _field,
          L.l(
              "Can't determine targetEntity for {0}.  @OneToMany properties must target @Entity beans.",
              _fieldName));

    AmberType targetType = persistenceUnit.createType(targetClass);

    if (targetType == null) {
      throw error(
          _field,
          L.l(
              "targetClass '{0}' is not a known element collection class for {1}.  The targetClass of a @ElementCollection must be a basic class.",
              targetClass.getName(), _fieldName));
    }

    /*
    if (_orderBy != null)
      calculateOrderBy(_orderBy);
    */

    addCollection(targetType);
  }
  private void introspectDiscriminatorValue(Class type, EntityType entityType) {
    DiscriminatorValue discValueAnn =
        (DiscriminatorValue) type.getAnnotation(DiscriminatorValue.class);

    String discriminatorValue = null;

    if (discValueAnn != null) discriminatorValue = discValueAnn.value();

    if (discriminatorValue == null || discriminatorValue.equals("")) {
      String name = entityType.getBeanClass().getSimpleName();

      discriminatorValue = name;
    }

    entityType.setDiscriminatorValue(discriminatorValue);
  }
Exemplo n.º 19
0
  public void marshal(DataOutputStream dos) {
    super.marshal(dos);
    try {
      minefieldID.marshal(dos);
      requestingEntityID.marshal(dos);
      dos.writeByte((byte) requestID);
      dos.writeByte((byte) requestedPerimeterPoints.size());
      dos.writeByte((byte) pad2);
      dos.writeByte((byte) sensorTypes.size());
      dos.writeInt((int) dataFilter);
      requestedMineType.marshal(dos);

      for (int idx = 0; idx < requestedPerimeterPoints.size(); idx++) {
        Point aPoint = requestedPerimeterPoints.get(idx);
        aPoint.marshal(dos);
      } // end of list marshalling

      for (int idx = 0; idx < sensorTypes.size(); idx++) {
        TwoByteChunk aTwoByteChunk = sensorTypes.get(idx);
        aTwoByteChunk.marshal(dos);
      } // end of list marshalling

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of marshal method
Exemplo n.º 20
0
  public int getMarshalledSize() {
    int marshalSize = 0;

    marshalSize = super.getMarshalledSize();
    marshalSize = marshalSize + minefieldID.getMarshalledSize(); // minefieldID
    marshalSize = marshalSize + requestingEntityID.getMarshalledSize(); // requestingEntityID
    marshalSize = marshalSize + 2; // minefieldSequenceNumbeer
    marshalSize = marshalSize + 1; // requestID
    marshalSize = marshalSize + 1; // pduSequenceNumber
    marshalSize = marshalSize + 1; // numberOfPdus
    marshalSize = marshalSize + 1; // numberOfMinesInThisPdu
    marshalSize = marshalSize + 1; // numberOfSensorTypes
    marshalSize = marshalSize + 1; // pad2
    marshalSize = marshalSize + 4; // dataFilter
    marshalSize = marshalSize + mineType.getMarshalledSize(); // mineType
    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      TwoByteChunk listElement = sensorTypes.get(idx);
      marshalSize = marshalSize + listElement.getMarshalledSize();
    }
    marshalSize = marshalSize + 1; // pad3
    for (int idx = 0; idx < mineLocation.size(); idx++) {
      Vector3Float listElement = mineLocation.get(idx);
      marshalSize = marshalSize + listElement.getMarshalledSize();
    }

    return marshalSize;
  }
Exemplo n.º 21
0
  public void unmarshal(DataInputStream dis) {
    super.unmarshal(dis);

    try {
      minefieldID.unmarshal(dis);
      requestingEntityID.unmarshal(dis);
      requestID = (short) dis.readUnsignedByte();
      numberOfPerimeterPoints = (short) dis.readUnsignedByte();
      pad2 = (short) dis.readUnsignedByte();
      numberOfSensorTypes = (short) dis.readUnsignedByte();
      dataFilter = dis.readInt();
      requestedMineType.unmarshal(dis);
      for (int idx = 0; idx < numberOfPerimeterPoints; idx++) {
        Point anX = new Point();
        anX.unmarshal(dis);
        requestedPerimeterPoints.add(anX);
      }

      for (int idx = 0; idx < numberOfSensorTypes; idx++) {
        TwoByteChunk anX = new TwoByteChunk();
        anX.unmarshal(dis);
        sensorTypes.add(anX);
      }

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of unmarshal method
Exemplo n.º 22
0
  /**
   * Unpacks a Pdu from the underlying data.
   *
   * @throws java.nio.BufferUnderflowException if buff is too small
   * @see java.nio.ByteBuffer
   * @param buff The ByteBuffer at the position to begin reading
   * @since ??
   */
  public void unmarshal(java.nio.ByteBuffer buff) {
    super.unmarshal(buff);

    minefieldID.unmarshal(buff);
    requestingEntityID.unmarshal(buff);
    minefieldSequenceNumbeer = (int) (buff.getShort() & 0xFFFF);
    requestID = (short) (buff.get() & 0xFF);
    pduSequenceNumber = (short) (buff.get() & 0xFF);
    numberOfPdus = (short) (buff.get() & 0xFF);
    numberOfMinesInThisPdu = (short) (buff.get() & 0xFF);
    numberOfSensorTypes = (short) (buff.get() & 0xFF);
    pad2 = (short) (buff.get() & 0xFF);
    dataFilter = buff.getInt();
    mineType.unmarshal(buff);
    for (int idx = 0; idx < numberOfSensorTypes; idx++) {
      TwoByteChunk anX = new TwoByteChunk();
      anX.unmarshal(buff);
      sensorTypes.add(anX);
    }

    pad3 = (short) (buff.get() & 0xFF);
    for (int idx = 0; idx < numberOfMinesInThisPdu; idx++) {
      Vector3Float anX = new Vector3Float();
      anX.unmarshal(buff);
      mineLocation.add(anX);
    }
  } // end of unmarshal method
Exemplo n.º 23
0
  @Override
  public boolean equalsImpl(Object obj) {
    boolean ivarsEqual = true;

    if (!(obj instanceof MinefieldDataPdu)) return false;

    final MinefieldDataPdu rhs = (MinefieldDataPdu) obj;

    if (!(minefieldID.equals(rhs.minefieldID))) ivarsEqual = false;
    if (!(requestingEntityID.equals(rhs.requestingEntityID))) ivarsEqual = false;
    if (!(minefieldSequenceNumbeer == rhs.minefieldSequenceNumbeer)) ivarsEqual = false;
    if (!(requestID == rhs.requestID)) ivarsEqual = false;
    if (!(pduSequenceNumber == rhs.pduSequenceNumber)) ivarsEqual = false;
    if (!(numberOfPdus == rhs.numberOfPdus)) ivarsEqual = false;
    if (!(numberOfMinesInThisPdu == rhs.numberOfMinesInThisPdu)) ivarsEqual = false;
    if (!(numberOfSensorTypes == rhs.numberOfSensorTypes)) ivarsEqual = false;
    if (!(pad2 == rhs.pad2)) ivarsEqual = false;
    if (!(dataFilter == rhs.dataFilter)) ivarsEqual = false;
    if (!(mineType.equals(rhs.mineType))) ivarsEqual = false;

    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      if (!(sensorTypes.get(idx).equals(rhs.sensorTypes.get(idx)))) ivarsEqual = false;
    }

    if (!(pad3 == rhs.pad3)) ivarsEqual = false;

    for (int idx = 0; idx < mineLocation.size(); idx++) {
      if (!(mineLocation.get(idx).equals(rhs.mineLocation.get(idx)))) ivarsEqual = false;
    }

    return ivarsEqual && super.equalsImpl(rhs);
  }
Exemplo n.º 24
0
  /**
   * Packs a Pdu into the ByteBuffer.
   *
   * @throws java.nio.BufferOverflowException if buff is too small
   * @throws java.nio.ReadOnlyBufferException if buff is read only
   * @see java.nio.ByteBuffer
   * @param buff The ByteBuffer at the position to begin writing
   * @since ??
   */
  public void marshal(java.nio.ByteBuffer buff) {
    super.marshal(buff);
    minefieldID.marshal(buff);
    requestingEntityID.marshal(buff);
    buff.putShort((short) minefieldSequenceNumbeer);
    buff.put((byte) requestID);
    buff.put((byte) pduSequenceNumber);
    buff.put((byte) numberOfPdus);
    buff.put((byte) mineLocation.size());
    buff.put((byte) sensorTypes.size());
    buff.put((byte) pad2);
    buff.putInt((int) dataFilter);
    mineType.marshal(buff);

    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      TwoByteChunk aTwoByteChunk = (TwoByteChunk) sensorTypes.get(idx);
      aTwoByteChunk.marshal(buff);
    } // end of list marshalling

    buff.put((byte) pad3);

    for (int idx = 0; idx < mineLocation.size(); idx++) {
      Vector3Float aVector3Float = (Vector3Float) mineLocation.get(idx);
      aVector3Float.marshal(buff);
    } // end of list marshalling
  } // end of marshal method
Exemplo n.º 25
0
  public void marshal(DataOutputStream dos) {
    super.marshal(dos);
    try {
      minefieldID.marshal(dos);
      requestingEntityID.marshal(dos);
      dos.writeShort((short) minefieldSequenceNumbeer);
      dos.writeByte((byte) requestID);
      dos.writeByte((byte) pduSequenceNumber);
      dos.writeByte((byte) numberOfPdus);
      dos.writeByte((byte) mineLocation.size());
      dos.writeByte((byte) sensorTypes.size());
      dos.writeByte((byte) pad2);
      dos.writeInt((int) dataFilter);
      mineType.marshal(dos);

      for (int idx = 0; idx < sensorTypes.size(); idx++) {
        TwoByteChunk aTwoByteChunk = sensorTypes.get(idx);
        aTwoByteChunk.marshal(dos);
      } // end of list marshalling

      dos.writeByte((byte) pad3);

      for (int idx = 0; idx < mineLocation.size(); idx++) {
        Vector3Float aVector3Float = mineLocation.get(idx);
        aVector3Float.marshal(dos);
      } // end of list marshalling

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of marshal method
Exemplo n.º 26
0
  @Override
  public boolean equalsImpl(Object obj) {
    boolean ivarsEqual = true;

    if (!(obj instanceof MinefieldQueryPdu)) return false;

    final MinefieldQueryPdu rhs = (MinefieldQueryPdu) obj;

    if (!(minefieldID.equals(rhs.minefieldID))) ivarsEqual = false;
    if (!(requestingEntityID.equals(rhs.requestingEntityID))) ivarsEqual = false;
    if (!(requestID == rhs.requestID)) ivarsEqual = false;
    if (!(numberOfPerimeterPoints == rhs.numberOfPerimeterPoints)) ivarsEqual = false;
    if (!(pad2 == rhs.pad2)) ivarsEqual = false;
    if (!(numberOfSensorTypes == rhs.numberOfSensorTypes)) ivarsEqual = false;
    if (!(dataFilter == rhs.dataFilter)) ivarsEqual = false;
    if (!(requestedMineType.equals(rhs.requestedMineType))) ivarsEqual = false;

    for (int idx = 0; idx < requestedPerimeterPoints.size(); idx++) {
      if (!(requestedPerimeterPoints.get(idx).equals(rhs.requestedPerimeterPoints.get(idx))))
        ivarsEqual = false;
    }

    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      if (!(sensorTypes.get(idx).equals(rhs.sensorTypes.get(idx)))) ivarsEqual = false;
    }

    return ivarsEqual && super.equalsImpl(rhs);
  }
Exemplo n.º 27
0
  // null means that we could not get the updated results, so leave the old results
  // empty list results means that we should save a no results marker
  public List<? extends ResultType> saveInCacheInsideExistingTransaction(
      KeyType key,
      List<? extends ResultType> newItems,
      Date now,
      boolean refetchedWithoutCheckingCache) {
    TxUtils.assertHaveTransaction();

    logger.debug("Saving new results in cache");

    List<EntityType> oldItems = mapper.queryExisting(key);

    // since we always load all items, this is as good as letting the database do it, and doesn't
    // require
    // hacking each individual oldItems
    sort(oldItems);

    if (newItems == null) return formResultTypeList(oldItems);

    // Delete old items if any, the noResultsMarker if none
    deleteCache(key);

    // This is perhaps superstitious, but we do have an ordering constraint that we must
    // remove the old items then insert the new, or it will cause a constraint violation
    em.flush();

    // save new results
    if (newItems.isEmpty()) {
      EntityType e = mapper.newNoResultsMarker(key);
      if (!e.isNoResultsMarker()) throw new RuntimeException("new no results marker isn't: " + e);
      e.setLastUpdated(now);
      em.persist(e);
      logger.debug("cached a no results marker for key {}", key);
    } else {
      // Note that we are relying on getting database ID ordering that matches
      // the order of newItems, so when we load from the cache we can get things
      // back in the same order.
      for (ResultType r : newItems) {
        EntityType e = mapper.entityFromResult(key, r);
        e.setLastUpdated(now);
        em.persist(e);
      }
      logger.debug("cached {} items for key {}", newItems.size(), key);
    }

    return newItems;
  }
 private void validateMetaTypes() {
   for (Collection<EntityType> entityTypes :
       Arrays.asList(
           context.supertypes.values(),
           context.entityTypes.values(),
           context.extensionTypes.values(),
           context.embeddableTypes.values(),
           context.projectionTypes.values())) {
     for (EntityType entityType : entityTypes) {
       for (Property property : entityType.getProperties()) {
         if (property.getInits() != null && property.getInits().size() > 0) {
           validateInits(entityType, property);
         }
       }
     }
   }
 }
Exemplo n.º 29
0
 /**
  * Packs a Pdu into the ByteBuffer.
  *
  * @throws java.nio.BufferOverflowException if buff is too small
  * @throws java.nio.ReadOnlyBufferException if buff is read only
  * @see java.nio.ByteBuffer
  * @param buff The ByteBuffer at the position to begin writing
  * @since ??
  */
 public void marshal(java.nio.ByteBuffer buff) {
   super.marshal(buff);
   orginatingEntityID.marshal(buff);
   receivingEntityID.marshal(buff);
   relationship.marshal(buff);
   partLocation.marshal(buff);
   namedLocationID.marshal(buff);
   partEntityType.marshal(buff);
 } // end of marshal method
  public BookmarkCollection GetAll() throws Exception {
    EntityType et = EntityType.GetEntityType(Bookmark.class);

    // run...
    String url = GetServiceUrl(et);
    Document doc = HttpHelper.DownloadXml(url, GetDownloadSettings());

    // load...
    return (BookmarkCollection) LoadEntities(doc, et);
  }