org.optaplanner.examples.taskassigning.domain.Employee Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optaplanner-examples Show documentation
Show all versions of optaplanner-examples Show documentation
OptaPlanner solves planning problems.
This lightweight, embeddable planning engine implements powerful and scalable algorithms
to optimize business resource scheduling and planning.
This module contains the examples which demonstrate how to use it in a normal Java application.
/*
* 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 org.optaplanner.examples.common.swingui.components.Labeled;
import com.thoughtworks.xstream.annotations.XStreamAlias;
@XStreamAlias("TaEmployee")
public class Employee extends TaskOrEmployee implements Labeled {
private String fullName;
private Set skillSet;
private Map 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 getSkillSet() {
return skillSet;
}
public void setSkillSet(Set skillSet) {
this.skillSet = skillSet;
}
public Map getAffinityMap() {
return affinityMap;
}
public void setAffinityMap(Map 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("").append(fullName).append("
");
toolText.append("Skills:
");
for (Skill skill : skillSet) {
toolText.append(skill.getLabel()).append("
");
}
toolText.append(" ");
return toolText.toString();
}
@Override
public String toString() {
return fullName;
}
}