summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver/src/server
diff options
context:
space:
mode:
authortspitzer2014-02-18 13:08:48 +0100
committertspitzer2014-02-18 13:08:48 +0100
commit75df905c97bc8bb4def5a3a6a87f301e364bc2ab (patch)
tree84ecc75cde752529f47c098526213768851e70a2 /Dozentenmodulserver/src/server
parentneue GUI Versionen (diff)
downloadtutor-module-75df905c97bc8bb4def5a3a6a87f301e364bc2ab.tar.gz
tutor-module-75df905c97bc8bb4def5a3a6a87f301e364bc2ab.tar.xz
tutor-module-75df905c97bc8bb4def5a3a6a87f301e364bc2ab.zip
SQL für VL funktioniert
Diffstat (limited to 'Dozentenmodulserver/src/server')
-rw-r--r--Dozentenmodulserver/src/server/ServerInterface.java5
-rw-r--r--Dozentenmodulserver/src/server/ServerMethod.java89
2 files changed, 86 insertions, 8 deletions
diff --git a/Dozentenmodulserver/src/server/ServerInterface.java b/Dozentenmodulserver/src/server/ServerInterface.java
index bce713c0..49d7adb9 100644
--- a/Dozentenmodulserver/src/server/ServerInterface.java
+++ b/Dozentenmodulserver/src/server/ServerInterface.java
@@ -2,6 +2,7 @@ package server;
import java.rmi.*;
import java.sql.ResultSet;
import java.util.ArrayList;
+import java.util.List;
import Models.User;
@@ -11,5 +12,7 @@ public interface ServerInterface extends Remote
public int DeleteFtpUser(String user) throws RemoteException;
public ArrayList<String> getImages() throws RemoteException;
public String getPathOfImage(String name) throws RemoteException;
-
+ public boolean writeVLdata(String imagename, String firstname, String lastname,String university, String Mail, String Tel, String Fak, boolean license, boolean internet, int ram, int cpu) throws RemoteException;
+ public List<Object[]> getImageList() throws RemoteException;
+ public List<String> getAllOS() throws RemoteException;
}
diff --git a/Dozentenmodulserver/src/server/ServerMethod.java b/Dozentenmodulserver/src/server/ServerMethod.java
index 1039e238..1f66fb6b 100644
--- a/Dozentenmodulserver/src/server/ServerMethod.java
+++ b/Dozentenmodulserver/src/server/ServerMethod.java
@@ -7,8 +7,11 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
import java.util.UUID;
import Models.*;
import sql.SQL;
@@ -17,7 +20,8 @@ import sql.SQL;
public class ServerMethod extends UnicastRemoteObject implements ServerInterface
{
protected static String m_strName;
-
+ SQL sql=new SQL();
+ Connection con=sql.getConnection();
public ServerMethod() throws RemoteException
{
@@ -63,8 +67,8 @@ public class ServerMethod extends UnicastRemoteObject implements ServerInterface
@Override
public int DeleteFtpUser(String user) throws RemoteException {
- SQL sql=new SQL();
- Connection con=sql.getConnection();
+
+
int ret = sql.DeleteUser(con, user);
return ret;
}
@@ -86,8 +90,7 @@ public class ServerMethod extends UnicastRemoteObject implements ServerInterface
public ArrayList<String> getImages(){
- SQL sql=new SQL();
- Connection con=sql.getConnection();
+
ResultSet rs= sql.getImage(con);
ArrayList<String> al=new ArrayList<String>();
try {
@@ -107,8 +110,7 @@ public class ServerMethod extends UnicastRemoteObject implements ServerInterface
public String getPathOfImage(String name){
String path = null;
- SQL sql=new SQL();
- Connection con=sql.getConnection();
+
ResultSet rs= sql.getPathOfImage(con, name);
try {
@@ -125,4 +127,77 @@ public class ServerMethod extends UnicastRemoteObject implements ServerInterface
return path;
}
+ @Override
+ public boolean writeVLdata(String imagename, String firstname,
+ String lastname, String university, String Mail, String Tel,
+ String Fak, boolean license, boolean internet, int ram, int cpu)
+ throws RemoteException {
+ String login="tete";
+ System.out.println("1");
+ int pk_institution=sql.setInstitution(con, university);
+ System.out.println("2");
+ int pk_person=sql.setPerson(con, login, lastname, firstname, Mail, new Date(), pk_institution);
+ System.out.println("3");
+ sql.setImageData(con, pk_person, license, internet, cpu, ram, imagename);
+ System.out.println("4");
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+
+ @Override
+ public List<Object[]> getImageList() throws RemoteException {
+
+ ResultSet resWith=sql.getImageListWithLectures(con);
+ ResultSet resWithout=sql.getImageListWithoutLectures(con);
+
+ try {
+ List<Object[]> listWith = ResSetToObject(resWith);
+ List<Object[]> listWithout=ResSetToObject(resWithout);
+ listWith.addAll(listWith.size(), listWithout);
+ return listWith;
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public List<Object[]> ResSetToObject(ResultSet res) throws SQLException
+ {
+
+ ResultSetMetaData rsmd = res.getMetaData();
+ List<Object[]> list=new ArrayList<>();
+ while(res.next()){
+ Object[] objects = new Object[rsmd.getColumnCount()];
+ // tanks to umit ozkan for the bug fix!
+ for(int i=0;i<rsmd.getColumnCount();i++){
+ objects[i]=res.getObject(i+1);
+ }
+ list.add(objects);
+
+ }
+ return list;
+ }
+
+
+
+ @Override
+ public List<String> getAllOS() throws RemoteException {
+ List<String> list=new ArrayList<>();
+ ResultSet rs=sql.getAllOS(con);
+ try {
+ while(rs.next())
+ {
+ list.add(rs.getString("name"));
+ }
+ return list;
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
} \ No newline at end of file