Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Database


      // expensive method
      Set<Integer> schemaIds = new HashSet<Integer>(schemas.size());
      for (UpdatableSchema s : schemas) {
        schemaIds.add(getId(s));
      }
      Database database = schemas.iterator().next().getSurrogate().getDatabase();
      try {
        find_entity_with_series = open(FIND_ENTITY_WITH_SERIES, database, find_entity_with_series);
        find_entity_with_series.setInt(1, ss.getNumber());
        ResultSet rs = find_entity_with_series.executeQuery();
        while (rs.next()) {
          if (schemaIds.contains(rs.getInt(1))) {
            Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
            Schema schema = database.getChronicle(entityKey).getSchema(true); // hope caching is on
            if (schemaIds.contains(getId(schema)))
              result.add(entityKey);
          }
        }
      } catch (Exception e) {
View Full Code Here


    if (schemas.size() > 0) {
      Set<Integer> schemaIds = new HashSet<Integer>(schemas.size());
      for (UpdatableSchema s : schemas) {
        schemaIds.add(getId(s));
      }
      Database database = schemas.iterator().next().getSurrogate().getDatabase();
      try {
        find_entity_with_schema = open(FIND_ENTITY_WITH_SCHEMA, database, find_entity_with_schema);
        ResultSet rs = find_entity_with_schema.executeQuery();
        while (rs.next()) {
          if (schemaIds.contains(rs.getInt(1))) {
View Full Code Here

   * @return a collection of chronicle surrogates
   * @throws T2DBException
   */
  public Collection<Surrogate> findChronicles(Property<?> property, Collection<UpdatableSchema> schemas) throws T2DBException {
    Collection<Surrogate> result = new ArrayList<Surrogate>();
    Database database = property.getSurrogate().getDatabase();
    // expensive
    Set<Integer> schemaIds = new HashSet<Integer>(schemas.size());
    for(UpdatableSchema s : schemas) {
      schemaIds.add(getId(s));
    }
    try {
      find_entity_with_property = open(FIND_ENTITY_WITH_PROPERTY, property, find_entity_with_property);
      find_entity_with_property.setInt(1, getId(property));
      ResultSet rs = find_entity_with_property.executeQuery();
      while(rs.next()) {
        if (schemaIds.contains(rs.getInt(1))) {
          Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
          Schema schema = database.getChronicle(entityKey).getSchema(true); // hope caching is on
          if (schemaIds.contains(getId(schema)))
            result.add(entityKey);
        }
      }
    } catch (Exception e) {
View Full Code Here

    if (check(Permission.DISCOVER, parent, false)) {
      try {
        select_entities_by_parent = open(SELECT_ENTITIES_BY_PARENT, parent, select_entities_by_parent);
        select_entities_by_parent.setInt(1, getIdOrZero(parent));
        ResultSet rs = select_entities_by_parent.executeQuery();
        Database database = parent.getSurrogate().getDatabase();
        while (rs.next()) {
          int id = rs.getInt(1);
          if (id == 0)
            throw T2DBMsg.exception(E.E40105, parent == null ? null : parent.toString(), rs.getString(3));
          Surrogate surrogate = makeSurrogate(database, DBObjectType.CHRONICLE, id);
View Full Code Here

   * @return true if any value found
   * @throws T2DBException
   */
  public boolean getAttributeValue(List<Chronicle> chronicles, Attribute<?> attribute) throws T2DBException {
    // note: things would be easier here with Spring's SimpleJdbcTemplate and a named parameter
    Database db = null;
    if (sel_attibute_prop_in_ent == null)
      sel_attibute_prop_in_ent = new PreparedStatement[MAX_ENTITY_DEPTH];
   
    // index zero reserved for MAX_ENTITY_DEPTH elements or more
    int found = 0;
View Full Code Here

    if (check(Permission.DISCOVER, parent, false)) {
      try {
        select_entities_by_parent = open(SELECT_ENTITIES_BY_PARENT, parent, select_entities_by_parent);
        select_entities_by_parent.setInt(1, getIdOrZero(parent));
        ResultSet rs = select_entities_by_parent.executeQuery();
        Database database = parent.getSurrogate().getDatabase();
        while (rs.next()) {
          int id = rs.getInt(1);
          if (id == 0)
            throw T2DBJMsg.exception(J.J40105, parent == null ? null : parent.toString(), rs.getString(3));
          Surrogate surrogate = makeSurrogate(database, DBObjectType.CHRONICLE, id);
View Full Code Here

    return getProperties(vt).size() > 0;
  }
 
  private Collection<ObjectId> getProperties(ValueType<?> vt) throws T2DBException {
    try {
      Database database = vt.getDatabase();
      DBCollection coll = methods.getMongoDB(database).getProperties();
      DBObject query = methods.mongoObject(MongoDatabase.FLD_PROP_VT, methods.getId(vt));
      DBCursor cursor = coll.find(query);
      Collection<ObjectId> result = new ArrayList<ObjectId>();
      try {
View Full Code Here

  private <T> boolean atLeastOneDefaultValue(ValueType<T> vt, T value) throws T2DBException {
    boolean foundOne = false;
    try {
      Collection<ObjectId> propOids = getProperties(vt);
      Database database = vt.getDatabase();
      DBCollection coll = methods.getMongoDB(database).getSchemas();
      for (ObjectId propOid : propOids) {
        foundOne = coll.findOne(methods.mongoObject(Operator.OR.op(),
          new com.mongodb.DBObject[] {
            methods.mongoObject(methods.compositeName(
View Full Code Here

  private <T>boolean atLeastOneActualValue(ValueType<T> vt, T value) throws T2DBException {
    boolean foundOne = false;
    try {
      Collection<ObjectId> propOids = getProperties(vt);
      Database database = vt.getDatabase();
      DBCollection coll = methods.getMongoDB(database).getAttributes();
      for (ObjectId propOid : propOids) {
        foundOne = coll.findOne(methods.mongoObject(
              MongoDatabase.FLD_ATTR_PROP, propOid,
              MongoDatabase.FLD_ATTR_VALUE, value)) != null;
View Full Code Here

    return foundOne;
  }
 
  private <T>boolean atLeastOneSchema(Property<T> prop) throws T2DBException {
    try {
      Database database = prop.getDatabase();
      DBCollection coll = methods.getMongoDB(database).getSchemas();
      ObjectId propOid = methods.getId(prop);
      return coll.findOne (methods.mongoObject(Operator.OR.op(),
          new com.mongodb.DBObject[] {
            methods.mongoObject(methods.compositeName(
View Full Code Here

TOP

Related Classes of ch.agent.crnickl.api.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.