/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.optaplanner.examples.taskassigning.domain;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.optaplanner.examples.common.swingui.components.Labeled;
@XStreamAlias("TaEmployee")
public class Employee extends TaskOrEmployee implements Labeled {
private String fullName;
private Set<Skill> skillSet;
private Map<Customer, Affinity> affinityMap;
public Employee() {
}
public Employee(long id, String fullName) {
super(id);
this.fullName = fullName;
skillSet = new LinkedHashSet<>();
affinityMap = new LinkedHashMap<>();
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public Set<Skill> getSkillSet() {
return skillSet;
}
public void setSkillSet(Set<Skill> skillSet) {
this.skillSet = skillSet;
}
public Map<Customer, Affinity> getAffinityMap() {
return affinityMap;
}
public void setAffinityMap(Map<Customer, Affinity> affinityMap) {
this.affinityMap = affinityMap;
}
// ************************************************************************
// Complex methods
// ************************************************************************
@Override
public Employee getEmployee() {
return this;
}
@Override
public Integer getEndTime() {
return 0;
}
/**
* @param customer never null
* @return never null
*/
public Affinity getAffinity(Customer customer) {
Affinity affinity = affinityMap.get(customer);
if (affinity == null) {
affinity = Affinity.NONE;
}
return affinity;
}
@Override
public String getLabel() {
return fullName;
}
public String getToolText() {
StringBuilder toolText = new StringBuilder();
toolText.append("<html><center><b>").append(fullName).append("</b><br/><br/>");
toolText.append("Skills:<br/>");
for (Skill skill : skillSet) {
toolText.append(skill.getLabel()).append("<br/>");
}
toolText.append("</center></html>");
return toolText.toString();
}
@Override
public String toString() {
return fullName;
}
}