Jo det kan jeg da.
I stubben ligger sub klassen ProjectManager som blandt andet indeholder ArrayListen projectList.
package Entities;
import java.util.ArrayList;
import java.util.List;
public class ProjectManager extends Employee
{
private int skillLevel;
private int availableTimeUnits;
private List<Project> projectList;
public ProjectManager() {
projectList = new ArrayList<Project>();
}
public ProjectManager(Integer id, String username, String password, String name, String email, boolean employed, int skillLevel, int availableTime)
{
super(id, username, password, name, email, employed);
this.skillLevel = skillLevel;
this.availableTimeUnits = availableTime;
projectList = new ArrayList<Project>();
}
public void setAvailableTimeUnits(int availableTimeUnits)
{
this.availableTimeUnits = availableTimeUnits;
}
public int getSkillLevel()
{
return skillLevel;
}
public void setSkillLevel(int skillLevel)
{
this.skillLevel = skillLevel;
}
public void setProjectList(List<Project> projectList)
{
this.projectList = projectList;
}
public int getAvailableTimeUnits()
{
return availableTimeUnits;
}
@Override
public List<Project> getProjectList()
{
return projectList;
}
@Override
public void addProject(Project project)
{
boolean exist = false;
for (Project p : projectList)
if (p.getId()==project.getId())
exist = true;
if (!exist)
projectList.add(project);
}
}
Klassen hentes i et DTO sammen med andre informationer og der er indlæst project objekter i listen.
package Entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Project implements Serializable
{
private Integer id;
private List<ProjectParticipant> projectParticipantList;
private ProjectManager projectmanager;
private SalesRepresentative salesRepresentative;
private String name;
public Project(Integer id, String name)
{
this.id = id;
this.name = name;
projectParticipantList = new ArrayList<ProjectParticipant>();
}
public List<ProjectParticipant> getProjectParticipantList()
{
return projectParticipantList;
}
public void setProjectParticipantList(List<ProjectParticipant> projectParticipantList)
{
this.projectParticipantList = projectParticipantList;
}
public ProjectManager getProjectmanager()
{
return projectmanager;
}
public void setProjectmanager(ProjectManager projectmanager)
{
this.projectmanager = projectmanager;
projectmanager.addProject(this);
}
public SalesRepresentative getSalesRepresentative()
{
return salesRepresentative;
}
public void setSalesRepresentative(SalesRepresentative salesRepresentative)
{
this.salesRepresentative = salesRepresentative;
this.salesRepresentative.addProject(this);
}
public void addProjectParticipant(ProjectParticipant projectparticipant)
{
boolean exist = false;
for (ProjectParticipant pp : projectParticipantList){
if (pp.getConsultant().getUsername().equalsIgnoreCase(projectparticipant.getConsultant().getUsername()) &&
pp.getSkill().getId() == projectparticipant.getSkill().getId())
exist=true;
}
if (!exist)
projectParticipantList.add(projectparticipant);
}
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public String getName() {
if (name !=null)
return name;
else
return "Fejl i navn";
}
}
På brugerfladen ændrer en bruger eksempelvis adgangskoden, hvilket sker uden problemer. Når ændringen gemmes i backend sker det med følgende metodekald.
package frontend;
import Entities.*;
import frontend.exceptions.CommandException;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import shout.*;
public class Assembler {
// Initiating attributes
private ShoutRemote sr;
private static Assembler assembler = null;
private Employee user = null;
private List<Skill> skillList;
private List<String> titleList;
private List<Employee> employeeList;
private Assembler() {
// Get connection to backend files
try {
Context c = new InitialContext();
sr = (ShoutRemote) c.lookup("shout.ShoutRemote");
} catch (Exception e) {
System.out.println(e);
}
}
// Following method sends Employee objekt to Backend
public void updateEmployee(Employee employee) throws Exception {
try {
sr.updateEmployee(employee);
} catch (Exception e) {
throw new CommandException("Opdatering mislykkedes i backend");
}
}
Interfacet ser således ud
package shout;
import Entities.Employee;
import Entities.LoginDTO;
import Entities.Project;
import Entities.Skill;
import java.util.List;
import javax.ejb.Remote;
/**
*
* @author SimonK
*/
@Remote
public interface ShoutRemote {
Skill createSkill(Skill skill);
LoginDTO employeeLogin(LoginDTO loginDTO) throws Exception;
Employee getEmployeeOfTheYear();
Project getProjectInfo(Project project);
Employee newEmployee(Employee employee);
Employee getEmployee(Employee employee);
void updateEmployee(Employee employee);
void updateSkill(Skill skill);
List test();
}
og den bagvedliggende sessionsbønne har følgende metode.
// Saving an employee
public void updateEmployee(Employee employee){
employeeList.put(employee.getUsername(), employee);
}
Som sagt er ProjectManager en sub klasse og det er den til klassen Employee.
En anden sub klasse til Employee er klassen BranchManager.
Den udmærker sig ved ikke at indeholde Arraylister. Derfor virker hele forløbet når det er den klasse vi gemmer.
Tilsyneladende er det stubben der fejler med følgende fejl melding
"IOP00810257: (MARSHAL) Could not load class Entities.Project"