Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Database


   * @return a chronicle or null
   * @throws T2DBException
   */
  public Chronicle getChronicleOrNull(Chronicle parent, String name) throws T2DBException {
    try {
      Database database = parent.getDatabase();
      DBObject obj = getMongoDB(database).getChronicles().findOne(
          mongoObject(MongoDatabase.FLD_CHRON_PARENT, getIdOrZero(parent),
          MongoDatabase.FLD_CHRON_NAME, name));
      if (obj != null) {
        Chronicle chronicle = unpack(database, (BasicDBObject) obj);
View Full Code Here


 
  public Collection<Chronicle> getChroniclesByParent(Chronicle parent) throws T2DBException {
    Collection<Chronicle> result = new ArrayList<Chronicle>();
    if (check(Permission.DISCOVER, parent, false)) {
      try {
        Database db = parent.getDatabase();
        DBCursor cursor = getMongoDB(db).getChronicles().find(
            mongoObject(MongoDatabase.FLD_CHRON_PARENT, getIdOrZero(parent)));
        try {
          while (cursor.hasNext()) {
            Chronicle chronicle = unpack(db, (BasicDBObject) cursor.next());
View Full Code Here

   * @throws T2DBException
   */
  public boolean getAttributeValue(List<Chronicle> chronicles, Attribute<?> attribute) throws T2DBException {
    boolean found = false;
    Surrogate s = attribute.getProperty().getSurrogate();
    Database db = s.getDatabase();
    try {
      ObjectId[] chrOids = new ObjectId[chronicles.size()];
      int offset = 0;
      for(Chronicle chronicle : chronicles) {
        chrOids[offset++] = getId(chronicle);
View Full Code Here

   * @throws T2DBException
   */
  public <T>List<Chronicle> getChroniclesByAttributeValue(Property<T> property, T value, int maxSize) throws T2DBException {
    List<Chronicle> result = new ArrayList<Chronicle>();
    Surrogate s = property.getSurrogate();
    Database db = s.getDatabase();
    try {
      DBCursor cursor = getMongoDB(db).getAttributes().find(
          mongoObject(MongoDatabase.FLD_ATTR_PROP,
              getId(s), MongoDatabase.FLD_ATTR_VALUE,
              property.getValueType().toString(value)));
View Full Code Here

          if (map.put(numbers[i], i) != null)
            throw new IllegalArgumentException("duplicate number: " + numbers[i]);
        }
      }
      Surrogate s = chronicle.getSurrogate();
      Database db = s.getDatabase();
      try {
        check(Permission.READ, chronicle);
      } catch (Exception e) {
        throw T2DBMsg.exception(e, E.E40104, s.toString());
      }
View Full Code Here

public class T001_SetUpTest extends AbstractTest {

  public void test_setUp() {
    try {
      Database db = getContext().getDatabase();
      System.out.println(db.toString());
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

      if (def.isErasing()) {
        create_schema_component.setInt(4, 0);
        create_schema_component.setString(5, "");
        create_schema_component.setString(6, "");
      } else {
        Database database = schema.getSurrogate().getDatabase();
        Property<?> prop = ((JDBCDatabase)database).getReadMethodsForProperty().
            getProperty(def.getProperty().getSurrogate());
        if (prop == null)
          throw T2DBMsg.exception(E.E30130);
        create_schema_component.setInt(4, getId(prop));
View Full Code Here

   * @return a chronicle surrogate or null
   * @throws T2DBException
   */
  public Surrogate findChronicle(Schema schema) throws T2DBException {
    Surrogate result = null;
    Database database = schema.getSurrogate().getDatabase();
    try {
      find_entity_with_schema = open(FIND_ENTITY_WITH_SCHEMA, database, find_entity_with_schema);
      find_entity_with_schema.setInt(1, getId(schema));
      ResultSet rs = find_entity_with_schema.executeQuery();
      while (rs.next()) {
View Full Code Here

   * @return a surrogate or null
   * @throws T2DBException
   */
  public Surrogate findChronicle(Property<?> property, Schema schema) throws T2DBException {
    Surrogate result = null;
    Database database = property.getSurrogate().getDatabase();
    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()) {
        Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
        Schema s = database.getChronicle(entityKey).getSchema(true);
        if (s.dependsOnSchema(schema)) {
          result = entityKey;
          break;
        }
      }
View Full Code Here

   * @return a surrogate or null
   * @throws T2DBException
   */
  public Surrogate findChronicle(SeriesDefinition ss, Schema schema) throws T2DBException {
    Surrogate result = null;
    Database database = schema.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()) {
        Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
        Schema s = database.getChronicle(entityKey).getSchema(true);
        if (s.dependsOnSchema(schema)) {
          result = entityKey;
          break;
        }
      }
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.