Скачиваний:
61
Добавлен:
15.06.2014
Размер:
3.16 Кб
Скачать
package datacontainers;

import workingwithfiles.BaseProductFileReader;

/////////////////////////////////////////////////////////////
//ALL OPERATIONS WILL BE DONE BY DEPARTMENT CONTAINER CLASS
/////////////////////////////////////////////////////////////
public class BaseDepartmentContainer extends BaseContainer {
//all products department container
private BaseProductContainer allproducts_departmentcontainer = new BaseProductContainer();
//bought products department container
private BaseProductContainer boughtproducts_departmentcontainer = new BaseProductContainer();
//container for exceptions
private BaseExceptionContainer baseexceptioncontainer = new BaseExceptionContainer();

//objects that helps buy products

//base constructor
public BaseDepartmentContainer() {

}

//method for updating all products element
public BaseProductContainer updateAllProductsDepartmentContainer() {
//if all products container contains any elements
if(allproducts_departmentcontainer.getAllListOfProducts().size() != 0) {
//clear this container
allproducts_departmentcontainer.deleteAll();
//create object for reading from file
BaseProductFileReader baseproductfilereader = new BaseProductFileReader();
baseproductfilereader.readFromBaseProductFile(allproducts_departmentcontainer, "baseproductdata.xml");
}
//if all product container don't contain any elements
else {
//create object for reading from file
BaseProductFileReader baseproductfilereader = new BaseProductFileReader();
baseproductfilereader.readFromBaseProductFile(allproducts_departmentcontainer, "baseproductdata.xml");
}
//return all products container for cepochnie komandi vizovi
return allproducts_departmentcontainer;
}

//method for updating all bought products element
public BaseProductContainer updateBoughtProductsDepartmentContainer() {
//if bought products container contains any elements
if(boughtproducts_departmentcontainer.getAllListOfProducts().size() != 0) {
//clear this container
boughtproducts_departmentcontainer.deleteAll();
//create object for reading from file
BaseProductFileReader baseproductfilereader = new BaseProductFileReader();
baseproductfilereader.readFromBaseProductFile(boughtproducts_departmentcontainer, "boughtproducts.xml");
}
//if bought product container don't contain any elements
else {
//create object for reading from file
BaseProductFileReader baseproductfilereader = new BaseProductFileReader();
baseproductfilereader.readFromBaseProductFile(boughtproducts_departmentcontainer, "boughtproducts.xml");
}
//return bought product container
return boughtproducts_departmentcontainer;
}

public void generalUpdateDepartmentContainer() {
//update all departments
updateAllProductsDepartmentContainer();
updateBoughtProductsDepartmentContainer();
}

public BaseProductContainer getAllProductsContainer() {
return allproducts_departmentcontainer;
}

public BaseProductContainer getBoughtProductsContainer() {
return boughtproducts_departmentcontainer;
}
}
Соседние файлы в папке datacontainers