no message
This commit is contained in:
@@ -86,7 +86,7 @@ public abstract class Database {
|
||||
public DBObject InsertS(DBObject object) throws Exception {
|
||||
DBTable table = tables.get(object.getClass());
|
||||
if (!(object instanceof iDBObject) && table.Data.containsKey(object.getPK()))
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.Name) + " уже содержит объект с ключом " + Utils_.Brackets(object.getPK().toString()));
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.getName()) + " уже содержит объект с ключом " + Utils_.Brackets(object.getPK().toString()));
|
||||
insert(table, object);
|
||||
table.Data.put(object.getPK(), object);
|
||||
return object;
|
||||
@@ -113,7 +113,7 @@ public abstract class Database {
|
||||
table.Data.remove(o.getPK());
|
||||
return o;
|
||||
} else
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.Name) + " не содержит объект с ключом " + Utils_.Brackets(to_delete.getPK().toString()));
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.getName()) + " не содержит объект с ключом " + Utils_.Brackets(to_delete.getPK().toString()));
|
||||
}
|
||||
public DBObject DeleteByPK(Class object_class, Object key) throws Exception {
|
||||
DBTable table = tables.get(object_class);
|
||||
@@ -123,7 +123,7 @@ public abstract class Database {
|
||||
table.Data.remove(key);
|
||||
return o;
|
||||
} else
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.Name) + " не содержит объект с ключом " + Utils_.Brackets(key.toString()));
|
||||
throw new RepositoryRefuseException("Таблица " + Utils_.Brackets(table.getName()) + " не содержит объект с ключом " + Utils_.Brackets(key.toString()));
|
||||
}
|
||||
// не работает с автоинкрементом.
|
||||
public DBObject getObjectCopyByPK(Class table_class, Object pk) throws Exception {
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class DBTable<K, D extends DBObject> extends DataSet<K, D> {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder res = new StringBuilder(Name + "\n");
|
||||
StringBuilder res = new StringBuilder(getName() + "\n");
|
||||
for (DBTableColumn c : columns.values())
|
||||
res.append(c).append("\n");
|
||||
return res.toString();
|
||||
|
||||
@@ -9,18 +9,31 @@ import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public String Name;
|
||||
public Class<K> k; //класс первичного ключа.
|
||||
public Class<D> d; //класс объектов.
|
||||
public LinkedHashMap<K, D> Data = new LinkedHashMap<>(); //наполнение
|
||||
//-
|
||||
protected DataSetControlForm ui = null;
|
||||
DataSetControlForm ui = null;
|
||||
//--
|
||||
public DataSet(Class<K> k_in, Class<D> d_in) {
|
||||
k = k_in;
|
||||
d = d_in;
|
||||
Name = d.getSimpleName();
|
||||
}
|
||||
//---
|
||||
protected DataSetControlForm createUI(JPanel mountPanel) {
|
||||
return null;
|
||||
}
|
||||
//БАЗА ДАННЫХ
|
||||
public String getName() {
|
||||
return d.getSimpleName();
|
||||
}
|
||||
public String QName() {
|
||||
return "\"" + getName() + "\"";
|
||||
}
|
||||
public String getPKName() {
|
||||
return "";
|
||||
} //получить имя ключевого поля. нужно для таблиц.
|
||||
//ИНТЕРФЕЙС
|
||||
public DataSetControlForm<D> getUI() {
|
||||
return ui;
|
||||
}
|
||||
@@ -34,15 +47,17 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
ui.Clear();
|
||||
}
|
||||
}
|
||||
public void RefreshUI() {
|
||||
if (ui != null) ui.Refresh();
|
||||
public void ShowUI() {
|
||||
if (ui != null) {
|
||||
ui.Show();
|
||||
}
|
||||
}
|
||||
public int getRowCountUI() {
|
||||
return ui.getRowCount();
|
||||
}
|
||||
protected DataSetControlForm createUI(JPanel mountPanel) {
|
||||
return null;
|
||||
public void ShowUI(Object key) {
|
||||
if (ui != null) {
|
||||
ui.Show(key);
|
||||
}
|
||||
}
|
||||
//СОДЕРЖИМОЕ
|
||||
public D getFirstRecord() {
|
||||
return Data.values().stream().findFirst().orElse(null);
|
||||
}
|
||||
@@ -51,13 +66,6 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
res.sort(comparator);
|
||||
return res;
|
||||
}
|
||||
public String QName() {
|
||||
return "\"" + Name + "\"";
|
||||
}
|
||||
public String getPKName() {
|
||||
return "";
|
||||
} //получить имя ключевого поля. нужно для таблиц.
|
||||
//-
|
||||
public void put(Object key, D object) {
|
||||
Data.put((K) key, object);
|
||||
}
|
||||
@@ -73,16 +81,6 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public boolean containsKey(Object key) {
|
||||
return Data.containsKey(key);
|
||||
}
|
||||
public void ShowUI() {
|
||||
if (ui != null) {
|
||||
ui.Show();
|
||||
}
|
||||
}
|
||||
public void ShowUI(Object key) {
|
||||
if (ui != null) {
|
||||
ui.Show(key);
|
||||
}
|
||||
}
|
||||
public PassCode_ getDeletePassCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user