Архив

Публикации с меткой ‘View Object’

OAF: Вывести список VO и значения атрибутов

22 Август 2013 Нет комментариев

Вывести все View Objects (VO) и значения атрибутов для OAApplicationModule

    // Вывод всех значений VO
    public void printALLVO(OAApplicationModule am)
    {
      OADBTransaction tr = am.getOADBTransaction();
      if(tr.isLoggingEnabled(1)) 
      {
        tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " ",1);
        tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " AM "+am.getName(), 1);
      }
      String[] rootViewNames = am.getViewObjectNames();
      if(tr.isLoggingEnabled(1)) 
      {  
        tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " count of VOs from AM = " +rootViewNames.length,1 );
      }
      for (int j =0 ;j < rootViewNames.length ;j++ )
      {
        if(tr.isLoggingEnabled(1)) 
        {  
          tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " ",1);
          tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", "================",1);
          tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " VO "+rootViewNames[j],1 );
        }
     
        oracle.jbo.ViewObject lVO = (oracle.jbo.ViewObject)am.findViewObject(rootViewNames[j]);
        if (lVO!=null && lVO.isExecuted()) {
          oracle.jbo.server.ViewRowImpl lVORow;
          int numRow = 1;
          for(lVORow = (oracle.jbo.server.ViewRowImpl)lVO.first(); lVORow != null;
              lVORow = (oracle.jbo.server.ViewRowImpl)lVO.next())
          {
              if (lVORow!=null) {
                  int attrCount = lVORow.getAttributeCount();
                  if(tr.isLoggingEnabled(1)) 
                  {              
                    tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " ",1);
                    tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " [row "+numRow+"]",1);
                    tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " count of attributes = "+attrCount,1);
                  }
     
                  String[] attributeNames = lVORow.getAttributeNames();
                  for (int i = 0 ;i< attributeNames.length ;i++ )
                  {
                    if(tr.isLoggingEnabled(1)) 
                    {              
                      tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", attributeNames[i]
                      +" = "
                      +lVORow.getAttribute(i),1);
                    }
                  }
              }
              numRow ++;
          }
          if (numRow==1) {
            if(tr.isLoggingEnabled(1)) 
            {          
              tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " not exists rows",1);
            }
          }
        }
        else {
          if(tr.isLoggingEnabled(1)) 
          {                
            tr.writeDiagnostics(this.getClass().getName() + ".printALLVO XX", " not executed",1);
          }
        }
      }              
     
    }

Цикл по вложенным Application Modules (текущий AM не входит во вложенные AM)

String nestedAMArray[]=oapagecontext.getRootApplicationModule().getApplicationModuleNames();
for(int i = 0; i < nestedAMArray.length; i++)
{
    String amName = nestedAMArray[i];
    OAApplicationModule amIter = (OAApplicationModule)am.findApplicationModule(amName);
    oapagecontext.writeDiagnostics(this,"Nested AM Name=>"+amName,1);
}    

Создание View Object (VO) — только для просмотра данных

31 Май 2011 4 comments

Создадим View Object для следующего запроса

select empno,
       ename,
       job,
       mgr,
       hiredate,
       sal,
       comm,
       deptno
from scott.emp t
where t.deptno = 10;

EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO
----- ---------- --------- ----- ----------- --------- --------- ------
 7782 CLARK      MANAGER    7839 09.06.1981    2450.00               10
 7839 KING       PRESIDENT       17.11.1981    5000.00               10
 7934 MILLER     CLERK      7782 23.01.1982    1300.00               10

Номер департамента будем передавать в качестве параметра. VO будет только для просмотра данных, т.е. Entity Object создавать не будем.

Читать дальше про “Создание View Object (VO) — только для просмотра данных” »