package pt.estgp.estgweb.services.configuration;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import java.io.IOException;
import java.util.Iterator;
public class ConfigurationSeparatorsService
implements IService
{
private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger =
1.5.0/docs/api/java/util/logging/Logger.html">Logger.
getLogger(ConfigurationSeparatorsService.
class);
public ConfigurationSeparatorImpl newConfigurationSeparator
(UserSession session
) throws 1.5.0/docs/api/java/io/IOException.html">IOException
{
ConfigurationSeparatorImpl separator = DomainObjectFactory.
createConfigurationSeparatorImpl();
separator.
setActive(false);
DaoFactory.
getConfigurationSeparatorDaoImpl().
save(separator
);
return separator
;
}
public ConfigurationSeparatorImpl removeConfigurationSeparator
(1.5.0/docs/api/java/lang/String.html">String json,UserSession session
) throws 1.5.0/docs/api/java/io/IOException.html">IOException
{
ConfigurationSeparatorImpl config = ConfigurationSeparatorImpl.
loadFromJson(json
);
ConfigurationSeparatorImpl configPersistent =
(ConfigurationSeparatorImpl
) DaoFactory.
getConfigurationSeparatorDaoImpl().
load(config.
getId());
DaoFactory.
getConfigurationSeparatorDaoImpl().
delete(configPersistent
);
return configPersistent
;
}
public ConfigurationSeparatorImpl updateConfigurationSeparator
(1.5.0/docs/api/java/lang/String.html">String json, UserSession session
) throws 1.5.0/docs/api/java/io/IOException.html">IOException
{
ConfigurationSeparatorImpl config = ConfigurationSeparatorImpl.
loadFromJson(json
);
ConfigurationSeparatorImpl configPersistent =
(ConfigurationSeparatorImpl
) DaoFactory.
getConfigurationSeparatorDaoImpl().
load(config.
getId());
configPersistent.
setName(config.
getName());
configPersistent.
setActive(config.
isActive());
configPersistent.
setPosition(config.
getPosition());
configPersistent.
setShowInBaco(config.
isShowInBaco());
configPersistent.
setShowInPae(config.
isShowInPae());
configPersistent.
setShowStudents(config.
isShowStudents());
configPersistent.
setShowTeachers(config.
isShowTeachers());
configPersistent.
setShowWorkers(config.
isShowWorkers());
configPersistent.
setName(config.
getName());
configPersistent.
setNameEs(config.
getNameEs());
configPersistent.
setNameEn(config.
getNameEn());
configPersistent.
setNameFr(config.
getNameFr());
configPersistent.
setDescription(config.
getDescription());
if(config.
getPageSection() ==
null)
configPersistent.
setPageSection(null);
else
{
PageSectionImpl section =
(PageSectionImpl
) DaoFactory.
getPageSectionDaoImpl().
get(config.
getPageSection().
getId());
configPersistent.
setPageSection(section
);
}
Iterator
<CourseSchool
> courseSchoolIterator = configPersistent.
getSchools().
iterator();
while(courseSchoolIterator.
hasNext())
{
courseSchoolIterator.
next();
courseSchoolIterator.
remove();
}
for(CourseSchool school: config.
getSchools())
{
CourseSchool scPersistent = DaoFactory.
getCourseSchoolDaoImpl().
get(school.
getId());
configPersistent.
getSchools().
add(scPersistent
);
}
return configPersistent
;
}
}