Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_weekendowa_20221008
Commits
200d3419
Commit
200d3419
authored
Dec 10, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adnotacje JAXB
parent
0ef1da81
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
14 deletions
+64
-14
DateTimeAdapter.java
...SoapSerwer/src/main/java/sklep/model/DateTimeAdapter.java
+18
-0
Order.java
PC33-SoapSerwer/src/main/java/sklep/model/Order.java
+16
-0
OrderProduct.java
PC33-SoapSerwer/src/main/java/sklep/model/OrderProduct.java
+9
-0
Product.java
PC33-SoapSerwer/src/main/java/sklep/model/Product.java
+9
-14
package-info.java
PC33-SoapSerwer/src/main/java/sklep/model/package-info.java
+12
-0
No files found.
PC33-SoapSerwer/src/main/java/sklep/model/DateTimeAdapter.java
0 → 100644
View file @
200d3419
package
sklep
.
model
;
import
java.time.LocalDateTime
;
import
javax.xml.bind.annotation.adapters.XmlAdapter
;
public
class
DateTimeAdapter
extends
XmlAdapter
<
String
,
LocalDateTime
>
{
@Override
public
LocalDateTime
unmarshal
(
String
s
)
{
return
LocalDateTime
.
parse
(
s
);
}
@Override
public
String
marshal
(
LocalDateTime
dt
)
{
return
dt
.
toString
();
}
}
PC33-SoapSerwer/src/main/java/sklep/model/Order.java
View file @
200d3419
...
@@ -7,11 +7,27 @@ import java.util.Collections;
...
@@ -7,11 +7,27 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
;
public
class
Order
{
public
class
Order
{
@XmlAttribute
(
name
=
"id"
)
private
Integer
orderId
;
private
Integer
orderId
;
@XmlAttribute
(
name
=
"customer-email"
)
private
String
customerEmail
;
private
String
customerEmail
;
@XmlElement
(
name
=
"order-date"
)
@XmlJavaTypeAdapter
(
DateTimeAdapter
.
class
)
private
LocalDateTime
orderDate
;
private
LocalDateTime
orderDate
;
@XmlAttribute
(
name
=
"status"
)
private
Status
orderStatus
;
private
Status
orderStatus
;
@XmlElementWrapper
(
name
=
"products"
)
@XmlElement
(
name
=
"product"
)
public
final
List
<
OrderProduct
>
products
=
new
ArrayList
<>();
public
final
List
<
OrderProduct
>
products
=
new
ArrayList
<>();
public
Order
()
{
public
Order
()
{
...
...
PC33-SoapSerwer/src/main/java/sklep/model/OrderProduct.java
View file @
200d3419
...
@@ -3,10 +3,19 @@ package sklep.model;
...
@@ -3,10 +3,19 @@ package sklep.model;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Objects
;
import
java.util.Objects
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
public
class
OrderProduct
{
public
class
OrderProduct
{
@XmlAttribute
(
name
=
"order-id"
)
private
Integer
orderId
;
private
Integer
orderId
;
@XmlAttribute
(
name
=
"product-id"
)
private
Integer
productId
;
private
Integer
productId
;
private
int
quantity
;
private
int
quantity
;
@XmlElement
(
name
=
"actual-price"
)
private
BigDecimal
actualPrice
;
private
BigDecimal
actualPrice
;
public
OrderProduct
()
{
public
OrderProduct
()
{
...
...
PC33-SoapSerwer/src/main/java/sklep/model/Product.java
View file @
200d3419
...
@@ -3,13 +3,16 @@ package sklep.model;
...
@@ -3,13 +3,16 @@ package sklep.model;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Objects
;
import
java.util.Objects
;
import
javax.xml.bind.annotation.XmlA
ccessTyp
e
;
import
javax.xml.bind.annotation.XmlA
ttribut
e
;
import
javax.xml.bind.annotation.Xml
AccessorType
;
import
javax.xml.bind.annotation.Xml
Element
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Product
{
public
class
Product
{
@XmlAttribute
(
name
=
"id"
)
private
Integer
productId
;
private
Integer
productId
;
@XmlElement
(
name
=
"product-name"
)
private
String
productName
;
private
String
productName
;
private
BigDecimal
price
;
private
BigDecimal
price
;
private
BigDecimal
vat
;
private
BigDecimal
vat
;
private
String
description
;
private
String
description
;
...
@@ -34,7 +37,7 @@ public class Product {
...
@@ -34,7 +37,7 @@ public class Product {
}
}
public
String
getProductName
()
{
public
String
getProductName
()
{
return
productName
.
toUpperCase
()
;
return
productName
;
}
}
public
void
setProductName
(
String
productName
)
{
public
void
setProductName
(
String
productName
)
{
...
@@ -45,16 +48,8 @@ public class Product {
...
@@ -45,16 +48,8 @@ public class Product {
return
price
;
return
price
;
}
}
// public void setPrice(BigDecimal price) {
public
void
setPrice
(
BigDecimal
price
)
{
// this.price = price;
this
.
price
=
price
;
// }
public
String
getNiespodzianka
()
{
return
"a kuku"
;
}
public
void
setNiespodzianka
(
String
x
)
{
}
}
public
BigDecimal
getVat
()
{
public
BigDecimal
getVat
()
{
...
...
PC33-SoapSerwer/src/main/java/sklep/model/package-info.java
0 → 100644
View file @
200d3419
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
package
sklep
.
model
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
/* Technologia JAXB (Java Architecture for XML Binding)
* to zautomatyzowane tłumaczenie obiektów Javy do XML i w drugą stronę.
*
* Istnieją pewne domyślne ustawienia, które pozwalają konwertować dane od razu,
* a dodatkowo za pomocą adnotacji (@Xml????) można wpłynąć na nazwy itp. ustawienia.
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment