Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
s4s
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Jeremy Pinzauti (Archived)
s4s
Commits
6ac94a45
Commit
6ac94a45
authored
7 years ago
by
sknobl2s
Browse files
Options
Downloads
Patches
Plain Diff
Transaction.java : Verkaeufer von String zu Int
TransactionControl.java: Logik erstellt
parent
4b906f34
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/s4s/modell/dto/Transaction.java
+4
-4
4 additions, 4 deletions
src/main/java/org/s4s/modell/dto/Transaction.java
src/main/java/org/s4s/process/control/TransactionControl.java
+42
-8
42 additions, 8 deletions
...main/java/org/s4s/process/control/TransactionControl.java
with
46 additions
and
12 deletions
src/main/java/org/s4s/modell/dto/Transaction.java
+
4
−
4
View file @
6ac94a45
...
@@ -11,21 +11,21 @@ package org.s4s.modell.dto;
...
@@ -11,21 +11,21 @@ package org.s4s.modell.dto;
*/
*/
public
class
Transaction
{
public
class
Transaction
{
private
String
verkaeufer
;
private
Integer
verkaeufer
;
private
User
kaeufer
;
private
User
kaeufer
;
private
Product
produkt
;
private
Product
produkt
;
public
Transaction
(
String
verkaeufer
,
User
kaeufer
,
Product
produkt
)
{
public
Transaction
(
Integer
verkaeufer
,
User
kaeufer
,
Product
produkt
)
{
this
.
verkaeufer
=
verkaeufer
;
this
.
verkaeufer
=
verkaeufer
;
this
.
kaeufer
=
kaeufer
;
this
.
kaeufer
=
kaeufer
;
this
.
produkt
=
produkt
;
this
.
produkt
=
produkt
;
}
}
public
String
getVerkaeufer
()
{
public
Integer
getVerkaeufer
()
{
return
verkaeufer
;
return
verkaeufer
;
}
}
public
void
setVerkaeufer
(
String
verkaeufer
)
{
public
void
setVerkaeufer
(
Integer
verkaeufer
)
{
this
.
verkaeufer
=
verkaeufer
;
this
.
verkaeufer
=
verkaeufer
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/s4s/process/control/TransactionControl.java
+
42
−
8
View file @
6ac94a45
...
@@ -3,10 +3,14 @@ package org.s4s.process.control;
...
@@ -3,10 +3,14 @@ package org.s4s.process.control;
import
com.vaadin.ui.UI
;
import
com.vaadin.ui.UI
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.s4s.dao.impl.AbstractDatabaseClass
;
import
org.s4s.dao.impl.AbstractDatabaseClass
;
import
org.s4s.exceptions.DAOException
;
import
org.s4s.exceptions.DAOException
;
import
org.s4s.modell.dto.Product
;
import
org.s4s.modell.dto.Product
;
import
org.s4s.modell.dto.Transaction
;
import
org.s4s.modell.dto.User
;
import
org.s4s.modell.dto.User
;
import
org.s4s.modell.dto.Warenkorb
;
import
org.s4s.services.db.JDBCConnection
;
import
org.s4s.services.util.Roles
;
import
org.s4s.services.util.Roles
;
/**
/**
...
@@ -15,23 +19,53 @@ import org.s4s.services.util.Roles;
...
@@ -15,23 +19,53 @@ import org.s4s.services.util.Roles;
*/
*/
public
class
TransactionControl
extends
AbstractDatabaseClass
{
public
class
TransactionControl
extends
AbstractDatabaseClass
{
String
verkaeufer
;
Transaction
transaktion
;
User
kaeufer
;
private
final
Statement
statement
=
JDBCConnection
.
getInstance
().
getStatement
();
Product
produkt
;
//Warenkorb warenkorb = Warenkorb.getInstance();
String
kaufer
=
(
String
)
UI
.
getCurrent
().
getSession
().
getAttribute
(
Roles
.
CURRENTUSER
);
//String kaeuferString = (String) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER);
public
void
createTransactions
()
throws
DAOException
,
SQLException
{
for
(
Product
p
:
Warenkorb
.
getInstance
().
inhalt
())
{
transaktion
.
setKaeufer
((
User
)
UI
.
getCurrent
().
getSession
().
getAttribute
(
Roles
.
CURRENTUSER
));
transaktion
.
setVerkaeufer
(
kaeuferinDB
(
p
.
getId
()));
transaktion
.
setProdukt
(
p
);
createTransactionInDB
(
transaktion
);
updateGekauftStatusInArtikel
(
transaktion
);
}
}
public
void
createTransaction
()
throws
DAOException
,
SQLException
{
public
Integer
kaeuferinDB
(
int
produktid
)
throws
DAOException
,
SQLException
{
Integer
verkaeufer
;
try
(
ResultSet
rs
=
executeQuery
(
"SELECT u.\"besitzer\""
+
" FROM \"ERR\".\"shop\" u , \"ERR\".\"artikel\" s"
try
(
ResultSet
rs
=
executeQuery
(
"SELECT u.\"besitzer\""
+
" FROM \"ERR\".\"shop\" u , \"ERR\".\"artikel\" s"
+
" WHERE u.shopid = s.shopid AND "
+
" WHERE u.shopid = s.shopid AND "
+
"s.artikelid'"
+
p
rodukt
.
getId
()
+
"';"
);)
{
+
"s.artikelid'"
+
transaktion
.
getP
rodukt
()
.
getId
()
+
"';"
);)
{
verkaeufer
=
rs
.
get
String
(
"besitzer"
);
verkaeufer
=
rs
.
get
Int
(
"besitzer"
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
new
DAOException
(
ex
);
throw
new
DAOException
(
ex
);
}
}
return
verkaeufer
;
}
public
void
createTransactionInDB
(
Transaction
transaktion
)
throws
DAOException
,
SQLException
{
try
{
statement
.
execute
(
"INSERT INTO \"ERR\".\"transaktion\" (verkaeufer, kaeufer, artikelid) VALUES("
+
transaktion
.
getVerkaeufer
()
+
","
+
transaktion
.
getKaeufer
().
getUserId
()
+
","
+
transaktion
.
getProdukt
().
getId
());
}
catch
(
SQLException
ex
)
{
throw
new
DAOException
(
ex
);
}
}
public
void
updateGekauftStatusInArtikel
(
Transaction
transaktion
)
throws
DAOException
,
SQLException
{
try
{
statement
.
execute
(
"UPDATE INTO \"ERR\".\"artikel\""
+
"SET gekauft = true"
+
"WHERE artikelid = "
+
transaktion
.
getProdukt
().
getId
());
}
catch
(
SQLException
ex
)
{
throw
new
DAOException
(
ex
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment