package net.sourceforge.fenixedu.domain.softwareLicenseManagement; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.RootDomainObject; public class SoftwareVersion extends SoftwareVersion_Base { protected SoftwareVersion(SoftwareApplication application, String versionId, String repositoryUrl, String serialNumber, String licenseMessage, LicenseModel model) { super(); setRootDomainObject(RootDomainObject.getInstance()); setApplication(application); setVersionIdentifier(versionId); setRepositoryUrl(repositoryUrl); setSerialNumber(serialNumber); setLicenseMessage(licenseMessage); setLicenseModel(model); } public boolean isPersonAbleToRequestLicense(Person person) { return getLicenseModel().getAvailabilityPolicy().isMember(person); } public void delete() { getLicenseModel().delete(); removeApplication(); removeRootDomainObject(); super.deleteDomainObject(); } public List getActiveLicenseRequests() { List requests = new ArrayList(); for (LicenseRequest request : getLicenseRequests()) { if (request.getActive()) { requests.add(request); } } return requests; } public int getActiveLicenseRequestsCount() { return getActiveLicenseRequests().size(); } public List getPendingLicenseRequests() { List requests = new ArrayList(); for (LicenseRequest request : getLicenseRequests()) { if (request.isPending()) { requests.add(request); } } return requests; } public int getPendingLicenseRequestsCount() { return getPendingLicenseRequests().size(); } public List getCancelledLicenseRequests() { List requests = new ArrayList(); for (LicenseRequest request : getLicenseRequests()) { if (request.isPending()) { requests.add(request); } } return requests; } public int getCancelledLicenseRequestsCount() { return getCancelledLicenseRequests().size(); } public boolean hasActiveRequestForPerson(Person person) { for (LicenseRequest request : getLicenseRequests()) { if (request.getRequestor() == person && (request.isPending() || request.getActive())) { return true; } } return false; } }