Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Surrogate


    boolean cycleDetected = !cycleDetector.add(rawSchema.getId());
   
    String name = rawSchema.getName();
    UpdatableSchema base = null;
    if (rawSchema.getParent() > 0 && !cycleDetected) {
      Surrogate parentKey = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getParent());
      RawSchema rawBaseSchema = getRawSchema(parentKey);
      if (rawBaseSchema == null)
        throw T2DBMsg.exception(E.E30116, rawSchema.getParent(), name);
      base = getSchema(database, rawBaseSchema, cycleDetector);
    }
    Surrogate surrogate = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getId());
    RawSchemaComponents rawComponents = getRawSchemaComponents(surrogate);
    Collection<AttributeDefinition<?>> attributeDefs = null;
    Collection<SeriesDefinition> seriesDefinitions = null;
    if (rawComponents != null) {
      attributeDefs = makeAttributeDefinitions(database, rawComponents.attributes);
View Full Code Here


   * @param schema a schema
   * @param base a base schema or null
   * @throws T2DBException
   */
  public void createSchema(UpdatableSchemaImpl schema, Schema base) throws T2DBException {
    Surrogate surrogate = null;
    Throwable cause = null;
    try {
      check(Permission.CREATE, schema);
      if (base != null)
        check(Permission.READ, base);
View Full Code Here

      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);
        }
      }
View Full Code Here

        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);
          }
        }
View Full Code Here

    try {
      select_valuetype_by_name = open(SELECT_VALUETYPE_BY_NAME, database, select_valuetype_by_name);
      select_valuetype_by_name.setString(1, name);
      ResultSet rs = select_valuetype_by_name.executeQuery();
      if (rs.next()) {
        Surrogate surrogate = makeSurrogate(database, DBObjectType.VALUE_TYPE, rs.getInt(1));
        return getValueType(surrogate, name, rs.getBoolean(2), rs.getString(4));
      } else
        return null;
    } catch (Exception e) {
      throw T2DBJMsg.exception(e, J.J10104, name);
View Full Code Here

    try {
      select_valuetype_by_pattern = open(SELECT_VALUETYPE_BY_PATTERN, database, select_valuetype_by_pattern);
      select_valuetype_by_pattern.setString(1, pattern);
      ResultSet rs = select_valuetype_by_pattern.executeQuery();
      while(rs.next()) {
        Surrogate surrogate = makeSurrogate(database, DBObjectType.VALUE_TYPE, rs.getInt(1));
        result.add(getValueType(surrogate, rs.getString(2), rs.getBoolean(3), rs.getString(5)));
      }
      return result;
    } catch (Exception e) {
      throw T2DBJMsg.exception(e, J.J10106, pattern);
View Full Code Here

   *
   * @param chronicle a chronicle
   * @throws T2DBException
   */
  public void createChronicle(Chronicle chronicle) throws T2DBException {
    Surrogate surrogate = null;
    Throwable cause = null;
    try {
      String name = chronicle.getName(false);
      ((DatabaseBackend)chronicle.getSurrogate().getDatabase()).getNamingPolicy().checkSimpleName(name, false); // redundant but bugs exist
      String description = chronicle.getDescription(false);
View Full Code Here

   *            a series
   * @throws T2DBException
   */
  public void createSeries(Series<?> series) throws T2DBException {
    Throwable cause = null;
    Surrogate surrogate = null;
    Chronicle chronicle = series.getChronicle();
    try {
      check(Permission.MODIFY, chronicle, true);
      create_series = open(CREATE_SERIES, series, create_series);
      create_series.setInt(1, getId(chronicle));
View Full Code Here

    cycleDetector.add(rawSchema.getId());
    UpdatableSchemaImpl schema = null;
    String name = rawSchema.getName();
    UpdatableSchema base = null;
    if (rawSchema.getParent() > 0) {
      Surrogate parentKey = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getParent());
      RawSchema brs = getRawSchema(parentKey);
      if (brs == null)
        throw T2DBJMsg.exception(J.J30116, rawSchema.getParent(), name);
      base = getSchema(database, brs, cycleDetector);
    }
    Surrogate surrogate = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getId());
    RawSchemaComponents rscs = getRawSchemaComponents(surrogate);
    if (rscs != null) {
      Collection<AttributeDefinition<?>> attributeDefs = makeAttributeDefinitions(database, rscs.attributes);
      Collection<SeriesDefinition> seriesDefinitions = makeSeriesSchemas(database, rscs.series);
      schema = new UpdatableSchemaImpl(name, base, attributeDefs, seriesDefinitions, surrogate);
View Full Code Here

      ResultSet rs = select_entity_by_parent_and_name.executeQuery();
      if (rs.next()) {
        int id = rs.getInt(1);
        if (id == 0)
          throw T2DBMsg.exception(E.E40105, parent == null ? null : parent.toString(), name);
        Surrogate surrogate = makeSurrogate(parent.getSurrogate().getDatabase(), DBObjectType.CHRONICLE, id);
        ChronicleImpl.RawData data = new ChronicleImpl.RawData();
        data.setSurrogate(surrogate);
        int schema = rs.getInt(2);
        data.setCollection(parent);
        data.setSchema(schema == 0 ? null : makeSurrogate(parent.getSurrogate().getDatabase(), DBObjectType.SCHEMA, schema));
View Full Code Here

TOP

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

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.