1.6 La clase GanttTableBase

Continuando con las clases necesarias para el Gantt explicaremos la GanttTableBase que como podéis deducir será la encargada de trabajar con los Datos.
Lo primero que deberemos hacer es crearnos una clase que extienda de la GanttTableBase.


//XBB :: http://axlearn2012.blogspot.com.es/ :: XBB_Gantt :: 20141208
class XBB_GanttTable_SchedEmpl extends GanttTableBase

{
       XBB_GanttTmpSchedEmpl ganttTmpSchedEmpl;
}



Esto lo podemos hacer en la tabla o en la clase como queramos. Nos crearemos un método que iniciaará los campos de nuestra tabla tmp.


public void initFromPSASchedEmplReservation(PSASchedEmplReservation _schedEmplReservation)
{

     HcmWorker            worker = HcmWorker::find(_schedEmplReservation.Worker);

     ganttTmpSchedEmpl.ActivityNumber = _schedEmplReservation.ActivityNumber;
     ganttTmpSchedEmpl.CalendarId        = XBB_GanttTable_SchedEmpl::getCalendarId(Worker.PersonnelNumber);

     ganttTmpSchedEmpl.ProjId                = _schedEmplReservation.ProjId;
     ganttTmpSchedEmpl.PSASchedEmplReservationRecId = _schedEmplReservation.RecId;
     ganttTmpSchedEmpl.StartDate          = _schedEmplReservation.TransDate;
     ganttTmpSchedEmpl.EndDate           = _schedEmplReservation.TransDate;
     ganttTmpSchedEmpl.StartTime         = _schedEmplReservation.StartTime;
     ganttTmpSchedEmpl.endTime           = _schedEmplReservation.endTime;
     ganttTmpSchedEmpl.PersonnelNumberId = worker.PersonnelNumber;



Aquí tenemos algunos métodos necesarios para que funcione nuestro Gantt:


protected void initGanttTableBaseData()
{
 
    ganttTableBaseData = XBB_GanttTable_SchedEmpl::newAllowUserModification(false);
}

public Common parmTableBuffer(Common _ganttTmpSchedEmpl = ganttTmpSchedEmpl)
{
 
    if(!prmisdefault(_ganttTmpSchedEmpl))
     {
           ganttTmpSchedEmpl.data(_ganttTmpSchedEmpl);
      }


 
return ganttTmpSchedEmpl;
}

protected void resetTableBuffer()
{
 
      ganttTmpSchedEmpl = null;
}

public static XBB_GanttTable_SchedEmpl construct()
{
 
    return new XBB_GanttTable_SchedEmpl();
}


Este también nos lo podríamos crear aquí o donde queramos, ya que no es un método que necesite ser sobrescrito, sino creado para conseguir el calendario del empleado.



public static server CalendarId getCalendarId(HcmPersonnelNumberId _hcmPersonnelNumberId)
{

     HcmWorker                         hcmWorker;
     HcmEmployment                 hcmEmployment;  
     WorkCalendarEmployment workCalendarEmployment;

     CalendarId                           ret;

 
    select firstonly CalendarId from workCalendarEmployment
          join recid from hcmEmployment
         where hcmEmployment.RecId          == workCalendarEmployment.Employment

               && hcmEmployment.LegalEntity == CompanyInfo::find().RecId
 
                  join recid from hcmWorker
                   where hcmEmployment.Worker == hcmWorker.RecId

                    && hcmWorker.PersonnelNumber == _hcmPersonnelNumberId;

      ret = workCalendarEmployment.CalendarId;
 
 
     return ret;
}

public static XBB_GanttTable_SchedEmpl newAllowUserModification(

        boolean _allowUserModification,
        boolean _keepBaseData = _allowUserModification){

      XBB_GanttTable_SchedEmpl ganttTable_SchedEmpl =         XBB_GanttTable_SchedEmpl::construct();

      ganttTable_SchedEmpl.parmAllowUserModification(_allowUserModification);
      ganttTable_SchedEmpl.parmKeepBaseData(_keepBaseData);
      ganttTable_SchedEmpl.init();
 
 
      return ganttTable_SchedEmpl;}


Descargar XBB_GanttTable_SchedEmpl

Comentarios