Package org.dom4j

Examples of org.dom4j.Attribute


    mappings.addAuxiliaryDatabaseObject( auxDbObject );
  }

  private static void extractRootAttributes(Element hmNode, Mappings mappings) {
    Attribute schemaNode = hmNode.attribute( "schema" );
    mappings.setSchemaName( ( schemaNode == null ) ? null : schemaNode.getValue() );

    Attribute catalogNode = hmNode.attribute( "catalog" );
    mappings.setCatalogName( ( catalogNode == null ) ? null : catalogNode.getValue() );

    Attribute dcNode = hmNode.attribute( "default-cascade" );
    mappings.setDefaultCascade( ( dcNode == null ) ? "none" : dcNode.getValue() );

    Attribute daNode = hmNode.attribute( "default-access" );
    mappings.setDefaultAccess( ( daNode == null ) ? "property" : daNode.getValue() );

    Attribute dlNode = hmNode.attribute( "default-lazy" );
    mappings.setDefaultLazy( dlNode == null || dlNode.getValue().equals( "true" ) );

    Attribute aiNode = hmNode.attribute( "auto-import" );
    mappings.setAutoImport( ( aiNode == null ) || "true".equals( aiNode.getValue() ) );

    Attribute packNode = hmNode.attribute( "package" );
    if ( packNode != null ) mappings.setDefaultPackage( packNode.getValue() );
  }
View Full Code Here


      java.util.Map inheritedMetas, Mappings mappings, RootClass entity)
      throws MappingException {

    // DB-OBJECTNAME

    Attribute schemaNode = node.attribute( "schema" );
    String schema = schemaNode == null ?
        mappings.getSchemaName() : schemaNode.getValue();

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table table = mappings.addTable(
        schema,
        catalog,
        getClassTableName( entity, node, schema, catalog, null, mappings ),
        getSubselect( node ),
            entity.isAbstract() != null && entity.isAbstract().booleanValue()
      );
    entity.setTable( table );
    bindComment(table, node);

    log.info(
        "Mapping class: " + entity.getEntityName() +
        " -> " + entity.getTable().getName()
      );

    // MUTABLE
    Attribute mutableNode = node.attribute( "mutable" );
    entity.setMutable( ( mutableNode == null ) || mutableNode.getValue().equals( "true" ) );

    // WHERE
    Attribute whereNode = node.attribute( "where" );
    if ( whereNode != null ) entity.setWhere( whereNode.getValue() );

    // CHECK
    Attribute chNode = node.attribute( "check" );
    if ( chNode != null ) table.addCheckConstraint( chNode.getValue() );

    // POLYMORPHISM
    Attribute polyNode = node.attribute( "polymorphism" );
    entity.setExplicitPolymorphism( ( polyNode != null )
      && polyNode.getValue().equals( "explicit" ) );

    // ROW ID
    Attribute rowidNode = node.attribute( "rowid" );
    if ( rowidNode != null ) table.setRowId( rowidNode.getValue() );

    Iterator subnodes = node.elementIterator();
    while ( subnodes.hasNext() ) {

      Element subnode = (Element) subnodes.next();
View Full Code Here

  public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
      java.util.Map inheritedMetas) throws MappingException {
    // transfer an explicitly defined entity name
    // handle the lazy attribute
    Attribute lazyNode = node.attribute( "lazy" );
    boolean lazy = lazyNode == null ?
        mappings.isDefaultLazy() :
        "true".equals( lazyNode.getValue() );
    // go ahead and set the lazy here, since pojo.proxy can override it.
    persistentClass.setLazy( lazy );

    String entityName = node.attributeValue( "entity-name" );
    if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
View Full Code Here

  }

  private static void bindPersistentClassCommonValues(Element node, PersistentClass entity,
      Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
    // DISCRIMINATOR
    Attribute discriminatorNode = node.attribute( "discriminator-value" );
    entity.setDiscriminatorValue( ( discriminatorNode == null )
      ? entity.getEntityName()
      : discriminatorNode.getValue() );

    // DYNAMIC UPDATE
    Attribute dynamicNode = node.attribute( "dynamic-update" );
    entity.setDynamicUpdate(
        dynamicNode != null && "true".equals( dynamicNode.getValue() )
    );

    // DYNAMIC INSERT
    Attribute insertNode = node.attribute( "dynamic-insert" );
    entity.setDynamicInsert(
        insertNode != null && "true".equals( insertNode.getValue() )
    );

    // IMPORT
    mappings.addImport( entity.getEntityName(), entity.getEntityName() );
    if ( mappings.isAutoImport() && entity.getEntityName().indexOf( '.' ) > 0 ) {
      mappings.addImport(
          entity.getEntityName(),
          StringHelper.unqualify( entity.getEntityName() )
        );
    }

    // BATCH SIZE
    Attribute batchNode = node.attribute( "batch-size" );
    if ( batchNode != null ) entity.setBatchSize( Integer.parseInt( batchNode.getValue() ) );

    // SELECT BEFORE UPDATE
    Attribute sbuNode = node.attribute( "select-before-update" );
    if ( sbuNode != null ) entity.setSelectBeforeUpdate( "true".equals( sbuNode.getValue() ) );

    // OPTIMISTIC LOCK MODE
    Attribute olNode = node.attribute( "optimistic-lock" );
    entity.setOptimisticLockMode( getOptimisticLockMode( olNode ) );

    entity.setMetaAttributes( getMetas( node, inheritedMetas ) );

    // PERSISTER
    Attribute persisterNode = node.attribute( "persister" );
    if ( persisterNode != null ) {
      try {
        entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode
          .getValue() ) );
      }
      catch (ClassNotFoundException cnfe) {
        throw new MappingException( "Could not find persister class: "
          + persisterNode.getValue() );
      }
    }

    // CUSTOM SQL
    handleCustomSQL( node, entity );

    Iterator tables = node.elementIterator( "synchronize" );
    while ( tables.hasNext() ) {
      entity.addSynchronizedTable( ( (Element) tables.next() ).attributeValue( "table" ) );
    }

    Attribute abstractNode = node.attribute( "abstract" );
    Boolean isAbstract = abstractNode == null
        ? null
            : "true".equals( abstractNode.getValue() )
            ? Boolean.TRUE
                      : "false".equals( abstractNode.getValue() )
                ? Boolean.FALSE
                              : null;
    entity.setAbstract( isAbstract );
  }
View Full Code Here

    return isCallable( e, true );
  }

  private static boolean isCallable(Element element, boolean supportsCallable)
      throws MappingException {
    Attribute attrib = element.attribute( "callable" );
    if ( attrib != null && "true".equals( attrib.getValue() ) ) {
      if ( !supportsCallable ) {
        throw new MappingException( "callable attribute not supported yet!" );
      }
      return true;
    }
View Full Code Here

    }
    return false;
  }

  private static ExecuteUpdateResultCheckStyle getResultCheckStyle(Element element, boolean callable) throws MappingException {
    Attribute attr = element.attribute( "check" );
    if ( attr == null ) {
      // use COUNT as the default.  This mimics the old behavior, although
      // NONE might be a better option moving forward in the case of callable
      return ExecuteUpdateResultCheckStyle.COUNT;
    }
    return ExecuteUpdateResultCheckStyle.parse( attr.getValue() );
  }
View Full Code Here

    if ( unionSubclass.getEntityPersisterClass() == null ) {
      unionSubclass.getRootClass().setEntityPersisterClass(
        UnionSubclassEntityPersister.class );
    }

    Attribute schemaNode = node.attribute( "schema" );
    String schema = schemaNode == null ?
        mappings.getSchemaName() : schemaNode.getValue();

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable();
    Table mytable = mappings.addDenormalizedTable(
        schema,
        catalog,
View Full Code Here

  private static String getClassTableName(
      PersistentClass model, Element node, String schema, String catalog, Table denormalizedSuperTable,
      Mappings mappings
  ) {
    Attribute tableNameNode = node.attribute( "table" );
    String logicalTableName;
    String physicalTableName;
    if ( tableNameNode == null ) {
      logicalTableName = StringHelper.unqualify( model.getEntityName() );
      physicalTableName = mappings.getNamingStrategy().classToTableName( model.getEntityName() );
    }
    else {
      logicalTableName = tableNameNode.getValue();
      physicalTableName = mappings.getNamingStrategy().tableName( logicalTableName );
    }
    mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
    return physicalTableName;
  }
View Full Code Here

    if ( joinedSubclass.getEntityPersisterClass() == null ) {
      joinedSubclass.getRootClass()
        .setEntityPersisterClass( JoinedSubclassEntityPersister.class );
    }

    Attribute schemaNode = node.attribute( "schema" );
    String schema = schemaNode == null ?
        mappings.getSchemaName() : schemaNode.getValue();

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table mytable = mappings.addTable(
        schema,
        catalog,
        getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
        getSubselect( node ),
        false
      );
    joinedSubclass.setTable( mytable );
    bindComment(mytable, node);

    log.info(
        "Mapping joined-subclass: " + joinedSubclass.getEntityName() +
        " -> " + joinedSubclass.getTable().getName()
      );

    // KEY
    Element keyNode = node.element( "key" );
    SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
    joinedSubclass.setKey( key );
    key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
    bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );

    // model.getKey().setType( new Type( model.getIdentifier() ) );
    joinedSubclass.createPrimaryKey();
    joinedSubclass.createForeignKey();

    // CHECK
    Attribute chNode = node.attribute( "check" );
    if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );

    // properties
    createClassProperties( node, joinedSubclass, mappings, inheritedMetas );

  }
View Full Code Here

    PersistentClass persistentClass = join.getPersistentClass();
    String path = persistentClass.getEntityName();

    // TABLENAME

    Attribute schemaNode = node.attribute( "schema" );
    String schema = schemaNode == null ?
        mappings.getSchemaName() : schemaNode.getValue();
    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();
    Table primaryTable = persistentClass.getTable();
    Table table = mappings.addTable(
        schema,
        catalog,
        getClassTableName( persistentClass, node, schema, catalog, primaryTable, mappings ),
        getSubselect( node ),
        false
      );
    join.setTable( table );
    bindComment(table, node);

    Attribute fetchNode = node.attribute( "fetch" );
    if ( fetchNode != null ) {
      join.setSequentialSelect( "select".equals( fetchNode.getValue() ) );
    }

    Attribute invNode = node.attribute( "inverse" );
    if ( invNode != null ) {
      join.setInverse( "true".equals( invNode.getValue() ) );
    }

    Attribute nullNode = node.attribute( "optional" );
    if ( nullNode != null ) {
      join.setOptional( "true".equals( nullNode.getValue() ) );
    }

    log.info(
        "Mapping class join: " + persistentClass.getEntityName() +
        " -> " + join.getTable().getName()
View Full Code Here

TOP

Related Classes of org.dom4j.Attribute

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.