Package businesslogic

Source Code of businesslogic.RowLL

package businesslogic;

import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.SortedSet;

import javax.swing.JTable;

import org.joda.time.DateTime;

import dataaccess.Artifact;
import dataaccess.ArtifactGroupList;
import dataaccess.ArtifactMessage;
import dataaccess.CVS_modul;
import dataaccess.CVS_revision;

public class CentralityEntity {
  private static boolean m_keepCentralities;
  private DateTime m_begin;
  private DateTime m_end;
  private long m_group_id;
  private long [][] m_communicationmatrix = null;
  private EdgeList m_edgelist;
  Hashtable <Double,Double> m_mappingtable = null;
  private double m_betweenness = 0;
  private double m_closeness = 0;
  private double m_degree = 0;
 
  private double[] m_actorbetweenness = null;
  private double[] m_actorcloseness = null;
  private double[] m_actordegree = null;
 
  public static LinkedList<Long> m_coredeveloper = null;
 

  public boolean calculateCentrality()
  {
    EdgeListVectors l_edgelistvectors = m_edgelist.getEdgelist();
   
    RInterface l_ri = new RInterface();
   
    Hashtable <String, double[]> tmpres = l_ri.calculateMeasures(l_edgelistvectors);
   
    m_degree = tmpres.get("degree")[0];
    m_closeness = tmpres.get("closeness")[0];
    m_betweenness = tmpres.get("betweenness")[0];
   
    m_actordegree = tmpres.get("actordegree");
    m_actorcloseness = tmpres.get("actorcloseness");
    m_actorbetweenness = tmpres.get("actorbetweenness");
     
    return true;
  }
 
  public EdgeListVectors getEdgelistVectors()
  {
    return m_edgelist.getEdgelist();
  }
 
  public boolean fillMatrixBugReports()
  {
    LinkedList<Long> groupartifact_ids = ArtifactGroupList.getGroupArtifactIDsByGroupID(m_group_id);

   
    DateTime interval_begin  = m_begin;
    DateTime interval_end = m_end;
    long i_position = 0;
   
    SNMatrix matrix = new SNMatrix();

      for(int i = 0; i < groupartifact_ids.size(); i++)
      {
        LinkedList<Long> artifacts = Artifact.getArtifacts(groupartifact_ids.get(i));

       
        for(int j = 0; j < artifacts.size(); j++)
        {
          LinkedList<ArtifactMessage> t_message = new LinkedList<ArtifactMessage>();
          LinkedList<Long> sn = new LinkedList<Long>();
         
          t_message.addAll(ArtifactMessage.getArtifactMessages(artifacts.get(j), new Date(interval_begin.getMillis()), new Date(interval_end.getMillis())));
         
         
          if(t_message.size() != 0)
          {
            Artifact tmp = new Artifact(artifacts.get(j), true);
           
            if(tmp.getM_open_date().after(new Date(interval_begin.getMillis())) == true &&
                tmp.getM_open_date().before(new Date(interval_end.getMillis())) == true && tmp.getM_submitted_by() != 100)
            {
              sn.add(tmp.getM_submitted_by());
            }
            
            for(int k= 0; k < t_message.size(); k++)
            {
              if(sn.contains(t_message.get(k).getM_submitted_by()) == false && t_message.get(k).getM_submitted_by() != 100)
                sn.add(t_message.get(k).getM_submitted_by());
            }
            
          }
         
          for (int l = 0; l < sn.size(); l ++)
          {
            for (int m = l+1; m < sn.size(); m++)
              m_edgelist.addEdge(sn.get(l), sn.get(m), 0);
             
          }
        }
      }
     
     
     
   
   
    return true;
  }
 

 
  public boolean fillMatrixForum()
  {
    return true;
  }
 
  public boolean fillMatrixSFCheckins()
  {
    DateTime interval_begin  = m_begin;
    DateTime interval_end = m_end;
   
    if(m_coredeveloper == null)
      m_coredeveloper = new LinkedList<Long>();
   
    try
    {
      LinkedList<Long> l_modules = CVS_modul.getModules(new Date(interval_begin.getMillis()), new Date(interval_end.getMillis()), m_group_id);
     
      for(int i = 0; i < l_modules.size(); i++)
      {
        LinkedList<Long> sn = new LinkedList<Long>();
        LinkedList<CVS_revision> l_revs = CVS_revision.getRevisions(l_modules.get(i), new Date(interval_begin.getMillis()), new Date(interval_end.getMillis()));
       
        for (int j = 0; j < l_revs.size(); j++)
          {
            if(sn.contains(l_revs.get(j).getM_revision_user_id()) == false)
              sn.add(l_revs.get(j).getM_revision_user_id());
           
            if(m_coredeveloper.contains(l_revs.get(j).getM_revision_user_id()) == false)
              m_coredeveloper.add(l_revs.get(j).getM_revision_user_id());
          }
       
       
        for (int l = 0; l < sn.size(); l ++)
        {
          for (int m = l+1; m < sn.size(); m++)
            m_edgelist.addEdge(sn.get(l), sn.get(m), 1);
        }
       
      }
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
    }
   
    return true;
  }

  public DateTime getM_begin() {
    return m_begin;
  }

  public CentralityEntity(DateTime mBegin, DateTime mEnd, long mGroupId, boolean keepCentralities) {
    m_begin = mBegin;
    m_end = mEnd;
    m_group_id = mGroupId;
    m_keepCentralities = keepCentralities;
    m_mappingtable = new Hashtable<Double, Double>();
   
    m_edgelist = new EdgeList(false, m_mappingtable);
  }
 
  public CentralityEntity(DateTime mBegin, DateTime mEnd, long mGroupId, boolean keepCentralities, Hashtable <Double,Double> i_matchingtable) {
    m_begin = mBegin;
    m_end = mEnd;
    m_group_id = mGroupId;
    m_keepCentralities = keepCentralities;

    m_edgelist = new EdgeList(false, i_matchingtable);          //create undirected edgelist object
  }

  public long getM_group_id() {
    return m_group_id;
  }

  public void setM_begin(DateTime mBegin) {
    m_begin = mBegin;
  }

  public DateTime getM_end() {
    return m_end;
  }

  public void setM_end(DateTime mEnd) {
    m_end = mEnd;
  }

  public long[][] getM_communicationmatrix() {
    return m_communicationmatrix;
  }


  public double getM_betweenness() {
    return m_betweenness;
  }
  public double getM_closeness() {
    return m_closeness;
  }

  public double getM_degree() {
    return m_degree;
  }
  public Hashtable<Double, Double> getM_mappingtable() {
    return m_mappingtable;
  }

  public double[] getM_actorbetweenness() {
    return m_actorbetweenness;
  }

  public void setM_actorbetweenness(double[] mActorbetweenness) {
    m_actorbetweenness = mActorbetweenness;
  }

  public double[] getM_actorcloseness() {
    return m_actorcloseness;
  }

  public void setM_actorcloseness(double[] mActorcloseness) {
    m_actorcloseness = mActorcloseness;
  }

  public double[] getM_actordegree() {
    return m_actordegree;
  }

  public void setM_actordegree(double[] mActordegree) {
    m_actordegree = mActordegree;
  }

  public void setM_mappingtable(Hashtable<Double, Double> mMappingtable) {
    m_mappingtable = mMappingtable;
  }
}

class RowLL {
    private String begin, end;
    SNMatrix val;
   
    public RowLL(String begin, String end, SNMatrix val) {
        this.begin = begin;
        this.end = end;
        this.val = val;
    }
    public String getBegin() {
        return begin;
    }
    public String getEnd() {
        return end;
    }
    public SNMatrix getVal() {
        return val;
    }
}
TOP

Related Classes of businesslogic.RowLL

TOP
Copyright © 2018 www.massapi.com. 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.