Дипломная работа: Автоматизированные системы управления технологическими процессами (на примере ООО "Заря")

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
77
* Возвращаетсодержимоефайла
* @return Содержимоефайла
*/
public byte[] getData() {
return data;
}
/**
* Задает содержимое файла
* @paramdata Содержимое файла
*/
public void setData(byte[] data) {
this.data = data;
}
/**
* Задает флаг контроля доступа
* @return Значение флага контроля доступа
*/
public Boolean getLocked() {
return locked;
}
/**
* Возвращает флаг контроля доступа
* @paramlocked Значение флага контроля доступа
*/
public void setLocked(Boolean locked) {
this.locked = locked;
}
/**
* Возвращает коллекцию правил доступа для данного документа
* @return Коллекция правил доступа (DocumentRule)
*/
@XmlTransient
public Collection<DocumentRule>getDocumentRuleCollection() {
returndocumentRuleCollection;
}
/**
* Задает коллекцию правил доступа для данного документа
* @paramdocumentRuleCollectionКоллекцияправилдоступа (DocumentRule)
*/
public void setDocumentRuleCollection(Collection<DocumentRule>documentRuleCollection) {
this.documentRuleCollection = documentRuleCollection;
}
/**
78
* Возвращаетколлекциюдочернихдокументов
* @return Коллекцияэлементов (Document)
*/
@XmlTransient
public Collection<Document>getDocumentCollection() {
returndocumentCollection;
}
/**
* Задает коллекцию дочерних документов
* @paramdocumentCollectionКоллекцияэлементов (Document)
*/
public void setDocumentCollection(Collection<Document>documentCollection) {
this.documentCollection = documentCollection;
}
/**
* Возвращаетродительскийдокумент
* @return Родительскийдокумент
*/
public Document getIdParentDocument() {
returnidParentDocument;
}
/**
* Задает родительский документ
* @paramidParentDocument Родительский документ
*/
public void setIdParentDocument(Document idParentDocument) {
this.idParentDocument = idParentDocument;
}
/**
* Возвращаеттипдокумента (файлилипапка)
* @return Тип документа (файл или папка)
*/
publicDocumentTypegetIdDocumentType() {
returnidDocumentType;
}
/**
* Задает тип документа (файл или папка)
* @paramidDocumentType Тип документа (файл или папка)
*/
public void setIdDocumentType(DocumentTypeidDocumentType) {
this.idDocumentType = idDocumentType;
}
/**
* Возвращает создателя документа
79
* @return Создательдокумента (User)
*/
public User getIdUser() {
returnidUser;
}
/**
* Задает создателя документа
* @paramidUser Создатель документа (User)
*/
public void setIdUser(User idUser) {
this.idUser = idUser;
}
/**
* Hash-кодэлемента
* @return Hash-значение
*/
@Override
publicinthashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
returnhash;
}
/**
* Метод сравнения двух объектов (проверка равенства)
* @paramobject Объект, который будет сравниваться с текущим
* @return Результатсравнения
*/
@Override
publicboolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Document)) {
return false;
}
Document other = (Document) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
returnfalse;
}
returntrue;
}
/**
* Метод вычисления названия объекта
* @return Название
*/
@Override
public String toString() {
80
return title;
}
/**
* Метод проверки "Имеет ли пользователь разрешение на просмотр текущего
документа"
* @paramuser Пользователь
* @return Результат проверки (да, нет)
*/
public Boolean testViewAccess(User user) {
if (user == null) {
return false;
}
if (locked == false) {
return true;
}
if (idUser.getId().equals(user.getId())) {
return true;
}
if (user.getIdUserType().getId().equals(1)) {
return true;
}
Collection<DocumentRule> rules = documentRuleCollection;
for (DocumentRule rule : rules) {
if ((rule.getIdUser() != null &&rule.getIdUser().getId().equals(user.getId())
&&rule.getAccessView())
|| (rule.getIdUserType() != null &&
rule.getIdUserType().getId().equals(user.getIdUserType().getId()) &&rule.getAccessView())) {
returntrue;
}
}
returnfalse;
}
/**
* Метод проверки "Имеет ли пользователь разрешение на просмотр текущего
документа" (возвращает исключение)
* @paramuser Пользователь
* @throwsException Результат проверки
*/
public void controlViewAccess(User user) throws Exception {
if (testViewAccess(user) == false) {
throw new
Exception(ResourceBundle.getBundle("/resources/Bundle").getString("AccessDenied"));
}
}
81
/**
* Метод проверки "Имеет ли пользователь разрешение на удаление текущего
документа"
* @paramuser Пользователь
* @return Результат проверки
*/
public Boolean testDeleteAccess(User user) {
if (user == null) {
return false;
}
if (locked == false) {
return true;
}
if (idUser.getId().equals(user.getId())) {
return true;
}
if (user.getIdUserType().getId().equals(1)) {
return true;
}
Collection<DocumentRule> rules = getDocumentRuleCollection();
for (DocumentRule rule : rules) {
if (rule.getIdUser() != null) {
if (rule.getIdUser().getId().equals(user.getId()) &&rule.getAccessDelete() == true) {
return true;
}
}
if (rule.getIdUserType() != null) {
if (rule.getIdUserType().getId().equals(user.getIdUserType().getId()) &&rule.getAccessDelete()
== true) {
returntrue;
}
}
}
returnfalse;
}
/**
* Метод проверки "Имеет ли пользователь разрешение на удаление текущего
документа" (возвращает исключение)
* @paramuser Пользователь
* @throwsException Результат проверки
*/
public void controlDeleteAccess(User user) throws Exception {
if (testDeleteAccess(user) == false) {
throw new
Exception(ResourceBundle.getBundle("/resources/Bundle").getString("AccessDenied"));
Источник: https://baza.diplomsite.ru/previewfile/2532