Package nexj.core.meta.persistence.sql

Examples of nexj.core.meta.persistence.sql.Index


   public void apply(RelationalSchemaUpgradeState state)
   {
      final RelationalSchema schema = state.getSchema();
      final Table table = schema.getTable(m_sTableName);

      m_index = new Index(m_outline.getName(), m_outline.getType(), table);
      m_outline.copyTo(m_index);
      table.addIndex(m_index);

      new RelationalSchemaAspectManager(schema)
      {
         protected Iterator getTableAspectIterator()
         {
            return schema.getTableIterator();
         }

         protected Iterator getTablePointcutIterator()
         {
            return EmptyIterator.getInstance();
         }

         protected Iterator getIndexAspectIterator()
         {
            return schema.getIndexIterator();
         }

         protected Iterator getIndexPointcutIterator()
         {
            return Collections.singletonList(m_index).iterator();
         }
      }.applyAspects(2);

      if (table.isAspect())
      {
         if (!m_index.isAspect())
         {
            for (Iterator itr = schema.getTableIterator(); itr.hasNext();)
            {
               Table pointcut = (Table)itr.next();

               if (pointcut.hasAspect(table))
               {
                  Index index = new Index(m_index.getName(pointcut), m_outline.getType(), table);

                  m_outline.copyTo(index);
                  pointcut.addIndex(index);

                  if (m_outline.getRelatedTableName() != null)
View Full Code Here


   {
      if (!state.removeIndex(m_outline.getName()) &&
         !state.containsTable(m_sTableName))
      {
         RelationalSchema schema = state.getSchema();
         Index index = schema.getIndex(m_outline.getName());

         schema.removeIndex(index);

         if (!index.isAspect() && index.getTable().isAspect())
         {
            for (Iterator itr = schema.getTableIterator(); itr.hasNext();)
            {
               Table pointcut = (Table)itr.next();

               if (pointcut.hasAspect(index.getTable()))
               {
                  String sName = index.getName(pointcut);

                  if (!state.removeIndex(sName))
                  {
                     schema.removeIndex(pointcut.getIndex(sName));
                  }
View Full Code Here

    */
   protected void createIndex(CreateIndexStep step)
   {
      step.apply(m_state);

      Index index = step.getIndex();
     
      if (!index.isAspect())
      {
         Table table = index.getTable();

         if (table.isAspect())
         {
            Table[] tableArray = getSortedTables(m_state.getSchema());

            for (int i = 0, nCount = tableArray.length; i < nCount; ++i)
            {
               Table pointcut = tableArray[i];

               if (pointcut.hasAspect(table))
               {
                  Index pointcutIndex = pointcut.getIndex(index.getName(pointcut));

                  if (!isUpgradedToPrimaryKey(pointcutIndex.getName()))
                  {
                     createIndex(pointcutIndex);
                  }
               }
            }
View Full Code Here

    * @param step The rename index step.
    */
   protected void renameIndex(RenameIndexStep step)
   {
      RelationalSchema schema = m_state.getSchema();
      Index oldIndex = schema.getIndex(step.getOldName()).getTable().cloneTemporary()
                          .getIndex(step.getOldName());

      step.apply(m_state);

      renameIndex(step.getIndex(), oldIndex);
View Full Code Here

    * @param step The drop index step.
    */
   protected void dropIndex(DropIndexStep step)
   {
      RelationalSchema schema = m_state.getSchema();
      Index index = schema.getIndex(step.getName());

      if (!index.isAspect())
      {
         if (index.getTable().isAspect())
         {
            Table[] tableArray = getSortedTables(m_state.getSchema());

            for (int i = 0, nCount = tableArray.length; i < nCount; ++i)
            {
               Table pointcut = tableArray[i];

               if (pointcut.hasAspect(index.getTable()))
               {
                  dropIndex(pointcut.getIndex(index.getName(pointcut)));
               }
            }
         }
         else
         {
View Full Code Here

    * @param step The remove index aspect step.
    */
   protected void removeIndexAspect(RemoveIndexAspectStep step)
   {
      RelationalSchema schema = m_state.getSchema();
      Index aspect = schema.getIndex(step.getAspectName());
      List pointcutList = new ArrayList();

      for (Iterator itr = step.getPointcutIterator(schema.getIndexIterator()); itr.hasNext();)
      {
         Index index = (Index)itr.next();

         if (index.hasAspect(aspect))
         {
            pointcutList.add(index);
            dropIndex(index);
         }
      }
View Full Code Here

         {
            targetCol.copyTo(templateCol);

            for (int k = template.getIndexCount() - 1; k >= 0; --k) // backwards due to removal
            {
               Index index = template.getIndex(k);

               if (index.findIndexColumn(templateCol) != null)
               {
                  template.removeIndex(index);
               }
            }
         }
View Full Code Here

         return; // NOOP
      }

      for (int i = 0, nCount = target.getIndexCount(); i < nCount; ++i)
      {
         Index targetInd = target.getIndex(i);
         Index currentInd = current.findIndex(targetInd.getName());

         if (currentInd == null && targetInd.getIndexColumnCount() > 0)
         {
            createIndex(targetInd);
            current.addIndex((Index)targetInd.clone());
View Full Code Here

   {
      Table table = column.getTable();

      for (int i = table.getIndexCount() - 1; i >= 0; --i) // backwards due to index removal
      {
         Index index = table.getIndex(i);

         if (index.findIndexColumn(column) != null)
         {
            dropIndex(index);

            if (bUpdate)
            {
View Full Code Here

         return; // NOOP
      }

      for (int i = current.getIndexCount() - 1; i >= 0; --i) // backwards due to index removal
      {
         Index currentInd = current.getIndex(i);
         Index targetInd = target.findIndex(currentInd.getName());

         // upgrade step applications leave indexes of size 0 which are invalid
         if (targetInd == null || targetInd.getIndexColumnCount() == 0)
         {
            dropIndex(currentInd);
            current.removeIndex(currentInd);
         }
      }
View Full Code Here

TOP

Related Classes of nexj.core.meta.persistence.sql.Index

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.