Author: bbrossaud Date: 2010-08-05 14:52:18 +0200 (Thu, 05 Aug 2010) New Revision: 123 Url: http://chorem.org/repositories/revision/bonzoms/123 Log: addition missing files and removed model Added: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressModel.java Removed: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressesModel.java trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/Model.java Added: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressModel.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressModel.java (rev 0) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressModel.java 2010-08-05 12:52:18 UTC (rev 123) @@ -0,0 +1,84 @@ +/* + * #%L + * Bonzoms : bonzoms-zk + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.bonzoms.ui; + +import java.util.ArrayList; +import java.util.List; +import org.chorem.data.bonzoms.Address; +import org.chorem.data.bonzoms.EmploymentContract; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zul.AbstractListModel; +import org.zkoss.zul.event.ListDataEvent; + +/** + * + * @author sherkhan + */ +public class AddressModel extends AbstractListModel implements BindingListModel { + + List<Address> addresses = new ArrayList<Address>(); + + @Override + public Object getElementAt(int index) { + return addresses.get(index); + } + + @Override + public int getSize() { + return addresses.size(); + } + + @Override + public int indexOf(Object obj) { + return addresses.indexOf(obj); + } + + public void setAddresses(List<Address> addresses) { + this.addresses = addresses; + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public void addData(Address newData) { + addresses.add(newData); + fireEvent(ListDataEvent.INTERVAL_ADDED, addresses.size() - 1, addresses.size() - 1); + } + + public void removeData(Address data) { + int interval = addresses.indexOf(data); + addresses.remove(data); + fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); + } + + public void reloadContent(int rowIndex) { + fireEvent(ListDataEvent.CONTENTS_CHANGED, rowIndex, rowIndex); + } + + public void reload() { + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public List<Address> getAddresses() { + return addresses; + } +} Deleted: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressesModel.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressesModel.java 2010-08-05 12:51:10 UTC (rev 122) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/AddressesModel.java 2010-08-05 12:52:18 UTC (rev 123) @@ -1,79 +0,0 @@ -/* - * #%L - * Bonzoms : bonzoms-zk - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.bonzoms.ui; - -import java.util.ArrayList; -import java.util.List; -import org.chorem.data.bonzoms.Address; -import org.zkoss.zkplus.databind.BindingListModel; -import org.zkoss.zul.AbstractListModel; -import org.zkoss.zul.event.ListDataEvent; - -/** - * - * @author sherkhan - */ -public class AddressesModel extends AbstractListModel implements BindingListModel { - - List<Address> addresses = new ArrayList<Address>(); - - @Override - public Object getElementAt(int index) { - return addresses.get(index); - } - - @Override - public int getSize() { - return addresses.size(); - } - - @Override - public int indexOf(Object obj) { - return addresses.indexOf(obj); - } - - public void setAddresses(List<Address> addresses) { - this.addresses = addresses; - fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); - } - - public void addData(Address newData) { - addresses.add(newData); - fireEvent(ListDataEvent.INTERVAL_ADDED, addresses.size() - 1, addresses.size() - 1); - } - - public void removeData(Address data) { - int interval = addresses.indexOf(data); - addresses.remove(data); - fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); - } - - public void reload() { - fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); - } - - public List<Address> getAddresses() { - return addresses; - } -} Deleted: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/Model.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/Model.java 2010-08-05 12:51:10 UTC (rev 122) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/Model.java 2010-08-05 12:52:18 UTC (rev 123) @@ -1,277 +0,0 @@ -/* - * #%L - * Bonzoms : bonzoms-zk - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.bonzoms.ui; - -import java.util.ArrayList; -import java.util.List; -import org.chorem.data.bonzoms.Address; -import org.chorem.data.bonzoms.Company; -import org.chorem.data.bonzoms.Employee; -import org.chorem.data.bonzoms.EmploymentContract; -import org.chorem.data.bonzoms.Person; -import org.chorem.data.bonzoms.Service; -import org.nuiton.wikitty.Criteria; -import org.nuiton.wikitty.PagedResult; -import org.nuiton.wikitty.Wikitty; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.WikittyService; -import org.nuiton.wikitty.search.Element; -import org.nuiton.wikitty.search.Search; - -/** - * - * @author sherkhan - */ -public class Model { - - protected WikittyProxy proxy; - - public Model() { - proxy = BonzomsProxy.getInstance(); - } - - /* - * Create - */ - public List<Address> createAddresses(List<Address> addresses) { - List<Address> wikitties = proxy.store(addresses); - return wikitties; - } - - public Employee createEmployee(Employee employee) { - return proxy.store(employee); - } - - public Address createAddress(Address address) { - return proxy.store(address); - } - - public Company createCompany(Company company) { - return proxy.store(company); - } - - public List<EmploymentContract> createContracts(List<EmploymentContract> contractsList) { - List<EmploymentContract> wikitties = proxy.store(contractsList); - return wikitties; - } - - public Person createPerson(Person person) { - return proxy.store(person); - } - - public EmploymentContract createContract(EmploymentContract contract) { - return proxy.store(contract); - } - - /* - * Retrieve - */ - public List<EmploymentContract> retrieveAllContracts() { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, EmploymentContract.EXT_EMPLOYMENTCONTRACT).criteria(); - List<EmploymentContract> contracts = proxy.findAllByCriteria(EmploymentContract.class, criteria).getAll(); - contracts = new ArrayList<EmploymentContract>(contracts); - return contracts; - } - - public Employee retrieveEmployeeById(String id) { - if (id == null || id.isEmpty()) { - return null; - } - return proxy.restore(Employee.class, id); - } - - public List<Employee> retrieveAllEmployees() { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Employee.EXT_EMPLOYEE).criteria(); - List<Employee> employees = proxy.findAllByCriteria(Employee.class, criteria).getAll(); - employees = new ArrayList<Employee>(employees); - return employees; - } - - public List<Service> retrieveAllServices() { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Service.EXT_SERVICE).criteria(); - List<Service> services = proxy.findAllByCriteria(Service.class, criteria).getAll(); - services = new ArrayList<Service>(services); - return services; - } - - public List<EmploymentContract> retrieveContractsByEmployeeId(String id) { - Criteria criteria = Search.query().eq(EmploymentContract.FQ_FIELD_EMPLOYEE, id).criteria(); - List<EmploymentContract> contracts = proxy.findAllByCriteria(EmploymentContract.class, criteria).getAll(); - contracts = new ArrayList<EmploymentContract>(contracts); - return contracts; - } - - public Person retrievePersonById(String id) { - if (id == null) { - return null; - } - return proxy.restore(Person.class, id); - } - - public List<Company> retrieveAllCompanies() { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Company.EXT_COMPANY).criteria(); - List<Company> companies = proxy.findAllByCriteria(Company.class, criteria).getAll(); - companies = new ArrayList<Company>(companies); - return companies; - } - - public Address retrieveAddressById(String id) { - if (id == null || id.isEmpty()) { - return null; - } - return proxy.restore(Address.class, id); - } - - public List<Address> retrieveAddressesByIds(List<String> ids) { - List<Address> addresses = proxy.restore(Address.class, ids); - return new ArrayList<Address>(addresses); - } - - public Service retrieveServiceById(String id) { - if (id == null || id.isEmpty()) { - return null; - } - return proxy.restore(Service.class, id); - } - - public List<EmploymentContract> retrieveContractsByIds(List<String> ids) { - List<EmploymentContract> contracts = proxy.restore(EmploymentContract.class, ids); - return new ArrayList<EmploymentContract>(contracts); - } - - public List<Person> retrieveAllPersons() { - Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Person.EXT_PERSON).criteria(); - List<Person> persons = proxy.findAllByCriteria(Person.class, criteria).getAll(); - persons = new ArrayList<Person>(persons); - return persons; - } - - public List<Employee> retrieveEmployeesBySearch(String search) { - Criteria criteria = Search.query().keyword(search).criteria(); - List<Employee> employees = proxy.findAllByCriteria(Employee.class, criteria).getAll(); - employees = new ArrayList<Employee>(employees); - return employees; - } - - public List<Company> retrieveCompaniesBySearch(String search) { - Criteria criteria = Search.query().keyword(search).criteria(); - List<Company> companies = proxy.findAllByCriteria(Company.class, criteria).getAll(); - companies = new ArrayList<Company>(companies); - return companies; - } - - public List<Service> retrieveServicesBySearch(String search) { - Criteria criteria = Search.query().keyword(search).criteria(); - List<Service> services = proxy.findAllByCriteria(Service.class, criteria).getAll(); - services = new ArrayList<Service>(services); - return services; - } - - public EmploymentContract retrieveContractById(String id) { - if (id == null || id.isEmpty()) { - return null; - } - return proxy.restore(EmploymentContract.class, id); - } - - public List<Wikitty> retrieveAllBySearch(String str) { - List<Wikitty> wikitties = new ArrayList<Wikitty>(); - - Search search = Search.query().eq(Element.ELT_EXTENSION, Person.EXT_PERSON); - search = search.or().eq(Element.ELT_EXTENSION, Company.EXT_COMPANY); - search = search.eq(Element.ELT_EXTENSION, Employee.EXT_EMPLOYEE); - search = search.eq(Element.ELT_EXTENSION, Service.EXT_SERVICE); - search = search.eq(Element.ELT_EXTENSION, EmploymentContract.EXT_EMPLOYMENTCONTRACT); - search = search.eq(Element.ELT_EXTENSION, Address.EXT_ADDRESS); - if (str != null && !str.isEmpty()) { - search = search.and().keyword(str); - } - - Criteria criteria = search.criteria(); - - WikittyService service = proxy.getWikittyService(); - String securityToken = proxy.getSecurityToken(); - PagedResult<?> result = service.findAllByCriteria(securityToken, criteria); - if (result != null) { - wikitties = result.cast(securityToken, service).getAll(); - wikitties = new ArrayList<Wikitty>(wikitties); - } - return wikitties; - } - - public Company retrieveCompanyById(String id) { - if (id == null || id.isEmpty()) { - return null; - } - return proxy.restore(Company.class, id); - } - - public Wikitty retrieveWikittyById(String id) { - WikittyService service = proxy.getWikittyService(); - return service.restore(proxy.getSecurityToken(), id); - } - - /* - * Update - */ - public List<Address> updatePersonAddresses(List<Address> addresses) { - List<Address> wikitties = proxy.store(addresses); - return wikitties; - } - - public Address updateAddress(Address address) { - return proxy.store(address); - } - - public Employee updateEmployee(Employee employee) { - return proxy.store(employee); - } - - public Company updateCompany(Company company) { - return proxy.store(company); - } - - public Service updateService(Service service) { - return proxy.store(service); - } - - /* - * Delete - */ - public void deleteAddressesByIds(List<String> ids) { - proxy.delete(ids); - } - - public void deletePhonesByIds(List<String> ids) { - proxy.delete(ids); - } - - public void deleteEmailsByIds(List<String> ids) { - proxy.delete(ids); - } - - public void deleteContractsByIds(List<String> removedContracts) { - proxy.delete(removedContracts); - } -}