├── .gitignore
├── README.md
├── images
├── github-32.png
├── java-32.png
└── postgresql-32.png
├── lecture1-intro
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── bin
│ └── intro
│ │ └── Main.class
└── src
│ └── intro
│ └── Main.java
├── lecture2-oopIntro
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── bin
│ ├── .gitignore
│ └── oopIntro
│ │ ├── Category.class
│ │ ├── Main.class
│ │ ├── Product.class
│ │ └── ProductService.class
└── src
│ └── oopIntro
│ ├── Category.java
│ ├── Main.java
│ ├── Product.java
│ └── ProductService.java
├── lecture2.2-homework
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── homework
│ ├── Main.java
│ ├── constant
│ ├── Message.java
│ └── Validation.java
│ ├── dto
│ ├── CourseDto.java
│ └── LectureDto.java
│ ├── model
│ ├── Category.java
│ ├── Course.java
│ ├── CourseParticipant.java
│ ├── Instructor.java
│ ├── InstructorNotificationOption.java
│ ├── Lecture.java
│ ├── LectureComment.java
│ ├── State.java
│ ├── Student.java
│ ├── User.java
│ ├── UserAddress.java
│ └── UserNotificationOption.java
│ ├── readme.md
│ └── service
│ ├── CategoryService.java
│ ├── CourseService.java
│ ├── InstructorService.java
│ ├── LectureService.java
│ ├── StudentService.java
│ └── UserService.java
├── lecture3.1-oopIntro2
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── oopIntro2
│ ├── Category.java
│ ├── Main.java
│ ├── Product.java
│ └── ProductManager.java
├── lecture3.2-inheritance
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── inheritance
│ ├── CorporateCustomer.java
│ ├── Customer.java
│ ├── CustomerManager.java
│ ├── IndividualCustomer.java
│ ├── Main.java
│ └── SyndicateCustomer.java
├── lecture3.3-inheritance2
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── inheritance2
│ ├── CustomerManager.java
│ ├── DatabaseLogger.java
│ ├── EmailLogger.java
│ ├── FileLogger.java
│ ├── LogManager.java
│ ├── Logger.java
│ └── Main.java
├── lecture3.4-homework
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── homework
│ ├── Main.java
│ ├── model
│ ├── Course.java
│ ├── Instructor.java
│ ├── Student.java
│ └── User.java
│ └── service
│ ├── InstructorManager.java
│ ├── StudentManager.java
│ └── UserManager.java
├── lecture4.1-interface
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── interfaces
│ ├── Customer.java
│ ├── CustomerManager.java
│ ├── DatabaseLogger.java
│ ├── EmailLogger.java
│ ├── FileLogger.java
│ ├── Logger.java
│ ├── Main.java
│ ├── SmsLogger.java
│ └── Utils.java
├── lecture4.2-homework2
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ └── org.eclipse.jdt.core.prefs
├── README.md
├── images
│ ├── 1.png
│ ├── 10.png
│ ├── 2.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ ├── 6.png
│ ├── 7.png
│ ├── 8.png
│ └── 9.png
├── libs
│ ├── activation.jar.zip
│ └── mail.jar.zip
└── src
│ ├── README.md
│ ├── homework2
│ ├── Main.java
│ ├── abstracts
│ │ ├── CustomerCheckManager.java
│ │ └── CustomerManager.java
│ ├── adapters
│ │ └── MernisServiceAdapter.java
│ ├── entities
│ │ └── Customer.java
│ ├── interfaces
│ │ ├── CustomerCheckService.java
│ │ ├── CustomerService.java
│ │ ├── Entity.java
│ │ ├── RealPersonService.java
│ │ └── Result.java
│ ├── services
│ │ ├── NeroCustomerManager.java
│ │ ├── StarbucksCustomerCheckManager.java
│ │ └── StarbucksCustomerManager.java
│ └── utils
│ │ ├── CheckServiceUtils.java
│ │ └── Result.java
│ └── tr
│ └── gov
│ └── nvi
│ └── tckimlik
│ └── WS
│ ├── KPSPublic.java
│ ├── KPSPublicLocator.java
│ ├── KPSPublicSoap.java
│ ├── KPSPublicSoapProxy.java
│ └── KPSPublicSoapStub.java
├── lecture4.3-homework3
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ └── org.eclipse.jdt.core.prefs
└── src
│ ├── homework3
│ ├── Abstract
│ │ ├── BaseProductManager.java
│ │ ├── BaseUserCheckManager.java
│ │ ├── BaseUserManager.java
│ │ ├── CampaignCheckService.java
│ │ ├── CampaignService.java
│ │ ├── CategoryService.java
│ │ ├── CrudService.java
│ │ ├── IdentityValidationService.java
│ │ ├── OrderCheckService.java
│ │ ├── OrderConfirmService.java
│ │ ├── OrderRefuseService.java
│ │ ├── OrderService.java
│ │ ├── ProductCheckService.java
│ │ ├── ProductService.java
│ │ ├── UserCheckService.java
│ │ └── UserService.java
│ ├── Adapter
│ │ └── MernisServiceAdapter.java
│ ├── Concrete
│ │ ├── CampaignManager.java
│ │ ├── CategoryManager.java
│ │ ├── GameManager.java
│ │ ├── GameProducerManager.java
│ │ ├── OrderManager.java
│ │ ├── PlayerCheckManager.java
│ │ ├── PlayerManager.java
│ │ └── SalesmanManager.java
│ ├── Entity
│ │ ├── Campaign.java
│ │ ├── Category.java
│ │ ├── Game.java
│ │ ├── GameProducer.java
│ │ ├── Order.java
│ │ ├── Player.java
│ │ ├── Product.java
│ │ ├── Salesman.java
│ │ └── User.java
│ ├── Main.java
│ ├── README.md
│ └── Utils
│ │ ├── Result
│ │ ├── ErrorResult.java
│ │ ├── Result.java
│ │ └── SuccessResult.java
│ │ └── ServiceUtils.java
│ └── tr
│ └── gov
│ └── nvi
│ └── tckimlik
│ └── WS
│ ├── KPSPublic.java
│ ├── KPSPublicLocator.java
│ ├── KPSPublicSoap.java
│ ├── KPSPublicSoapProxy.java
│ └── KPSPublicSoapStub.java
├── lecture5.1-nLayeredDemo
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── nLayeredDemo
│ ├── Main.java
│ ├── business
│ ├── abstracts
│ │ └── ProductService.java
│ └── concretes
│ │ └── ProductManager.java
│ ├── core
│ ├── JLoggerManagerAdapter.java
│ └── LoggerService.java
│ ├── dataAccess
│ ├── abstracts
│ │ └── ProductDao.java
│ └── concretes
│ │ ├── AbcProductDao.java
│ │ └── HibernateProductDao.java
│ ├── entities
│ ├── abstracts
│ │ └── Entity.java
│ └── concretes
│ │ └── Product.java
│ └── jLogger
│ └── JLoggerManager.java
├── lecture5.2-homework
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── homework
│ ├── Main.java
│ ├── business
│ ├── abstracts
│ │ ├── AuthCheckService.java
│ │ ├── AuthService.java
│ │ ├── BaseSignUpManager.java
│ │ ├── UserActivationService.java
│ │ ├── UserCheckService.java
│ │ ├── UserService.java
│ │ └── UserValidationService.java
│ ├── adapters
│ │ └── GoogleSignUpManagerAdapter.java
│ ├── concretes
│ │ ├── AuthCheckManager.java
│ │ ├── AuthManager.java
│ │ ├── SignUpManager.java
│ │ ├── UserActivationManager.java
│ │ ├── UserCheckManager.java
│ │ ├── UserManager.java
│ │ └── UserValidationManager.java
│ └── consts
│ │ └── Environment.java
│ ├── core
│ ├── dataAccess
│ │ └── abstracts
│ │ │ └── Entity.java
│ └── utils
│ │ ├── ServiceUtils.java
│ │ ├── consts
│ │ └── ValidationMessage.java
│ │ ├── crud
│ │ └── BaseCrud.java
│ │ ├── result
│ │ ├── ErrorResult.java
│ │ ├── Result.java
│ │ └── SuccessResult.java
│ │ ├── security
│ │ └── signUp
│ │ │ └── SignUpService.java
│ │ └── sendable
│ │ ├── Sendable.java
│ │ ├── SendableUtils.java
│ │ ├── mail
│ │ ├── CustomMailManager.java
│ │ ├── Mail.java
│ │ └── MailService.java
│ │ └── sms
│ │ ├── CustomSmsManager.java
│ │ ├── Sms.java
│ │ └── SmsService.java
│ ├── dataAccess
│ ├── abstracts
│ │ ├── Dao.java
│ │ ├── UserActivationDao.java
│ │ └── UserDao.java
│ └── concretes
│ │ └── inMemory
│ │ ├── InMemoryUserActivationDao.java
│ │ └── InMemoryUserDao.java
│ ├── entity
│ └── concretes
│ │ ├── User.java
│ │ └── UserActivation.java
│ └── googleAuth
│ └── GoogleSignUpManager.java
├── lecture6.1-springIntro
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── kodlamaio
│ │ │ └── northwind
│ │ │ ├── NorthwindApplication.java
│ │ │ ├── api
│ │ │ └── controllers
│ │ │ │ └── ProductsController.java
│ │ │ ├── business
│ │ │ ├── abstracts
│ │ │ │ └── ProductService.java
│ │ │ └── concretes
│ │ │ │ └── ProductManager.java
│ │ │ ├── dataAccess
│ │ │ └── abstracts
│ │ │ │ └── ProductDao.java
│ │ │ └── entity
│ │ │ └── concretes
│ │ │ └── Product.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── kodlamaio
│ └── northwind
│ └── NorthwindApplicationTests.java
├── lecture6.2-homework2
├── 19-05 Ders.sql
├── ER Diagram.3.png
├── README.MD
└── scripts.sql
├── lecture7.1-swagger
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── kodlamaio
│ │ │ └── northwind
│ │ │ ├── NorthwindApplication.java
│ │ │ ├── api
│ │ │ └── controllers
│ │ │ │ └── ProductsController.java
│ │ │ ├── business
│ │ │ ├── abstracts
│ │ │ │ └── ProductService.java
│ │ │ └── concretes
│ │ │ │ └── ProductManager.java
│ │ │ ├── core
│ │ │ └── utilities
│ │ │ │ └── results
│ │ │ │ ├── DataResult.java
│ │ │ │ └── Result.java
│ │ │ ├── dataAccess
│ │ │ └── abstracts
│ │ │ │ └── ProductDao.java
│ │ │ └── entity
│ │ │ └── concretes
│ │ │ └── Product.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── kodlamaio
│ └── northwind
│ └── NorthwindApplicationTests.java
├── lecture7.1-swaggerAndResult
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── kodlamaio
│ │ │ └── northwind
│ │ │ ├── NorthwindApplication.java
│ │ │ ├── api
│ │ │ └── controllers
│ │ │ │ └── ProductsController.java
│ │ │ ├── business
│ │ │ ├── abstracts
│ │ │ │ └── ProductService.java
│ │ │ └── concretes
│ │ │ │ └── ProductManager.java
│ │ │ ├── core
│ │ │ └── utilities
│ │ │ │ └── results
│ │ │ │ ├── DataResult.java
│ │ │ │ ├── ErrorDataResult.java
│ │ │ │ ├── ErrorResult.java
│ │ │ │ ├── Result.java
│ │ │ │ ├── SuccessDataResult.java
│ │ │ │ └── SuccessResult.java
│ │ │ ├── dataAccess
│ │ │ └── abstracts
│ │ │ │ └── ProductDao.java
│ │ │ └── entity
│ │ │ └── concretes
│ │ │ └── Product.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── kodlamaio
│ └── northwind
│ └── NorthwindApplicationTests.java
└── lecture8.1-springJPA
├── .gitignore
├── .mvn
└── wrapper
│ ├── MavenWrapperDownloader.java
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
├── main
├── java
│ └── kodlamaio
│ │ └── northwind
│ │ ├── NorthwindApplication.java
│ │ ├── api
│ │ └── controllers
│ │ │ └── ProductsController.java
│ │ ├── business
│ │ ├── abstracts
│ │ │ └── ProductService.java
│ │ └── concretes
│ │ │ └── ProductManager.java
│ │ ├── core
│ │ └── utilities
│ │ │ └── results
│ │ │ ├── DataResult.java
│ │ │ ├── ErrorDataResult.java
│ │ │ ├── ErrorResult.java
│ │ │ ├── Result.java
│ │ │ ├── SuccessDataResult.java
│ │ │ └── SuccessResult.java
│ │ ├── dataAccess
│ │ └── abstracts
│ │ │ └── ProductDao.java
│ │ └── entity
│ │ └── concretes
│ │ ├── Category.java
│ │ └── Product.java
└── resources
│ └── application.properties
└── test
└── java
└── kodlamaio
└── northwind
└── NorthwindApplicationTests.java
/.gitignore:
--------------------------------------------------------------------------------
1 | .plugins
2 | .plugins\
3 | .metadata
4 | .metadata\
5 | .idea
6 | .idea\
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Java & React Bootcamp (https://kodlama.io/)
2 | ## Lectures
3 | - **Lecture 1**
4 | - [*intro*](https://github.com/karcan/javaBootcamp/tree/master/lecture1-intro/src/intro)
5 | - **Lecture 2**
6 | - [*oopIntro*](https://github.com/karcan/javaBootcamp/tree/master/lecture2-oopIntro/src/oopIntro)
7 | - [*homework*](https://github.com/karcan/javaBootcamp/tree/master/lecture2.2-homework/src/homework)
8 | - **Lecture 3**
9 | - [*oopIntro2*](https://github.com/karcan/javaBootcamp/tree/master/lecture3.1-oopIntro2/src/oopIntro2)
10 | - [*inheritance*](https://github.com/karcan/javaBootcamp/tree/master/lecture3.2-inheritance/src/inheritance)
11 | - [*inheritance2*](https://github.com/karcan/javaBootcamp/tree/master/lecture3.3-inheritance2/src/inheritance2)
12 | - [*homework*](https://github.com/karcan/javaBootcamp/tree/master/lecture3.4-homework/src/homework)
13 | - **Lecture 4**
14 | - [*interface*](https://github.com/karcan/javaBootcamp/tree/master/lecture4.1-interface/src/interfaces)
15 | - [*homework2*](https://github.com/karcan/javaBootcamp/tree/master/lecture4.2-homework2/src)
16 | - [*homework3*](https://github.com/karcan/javaBootcamp/tree/master/lecture4.3-homework3/src/homework3)
17 | - **Lecture 5**
18 | - [*nLayeredDemo*](https://github.com/karcan/javaBootcamp/tree/master/lecture5-nLayeredDemo/src/nLayeredDemo)
19 | - [*homework*](https://github.com/karcan/javaBootcamp/tree/master/lecture5.2-homework/src/homework)
20 | - **Lecture 6**
21 | - [*springIntro*](https://github.com/karcan/javaBootcamp/tree/master/lecture6.1-springIntro/src/main/java/kodlamaio/northwind)
22 | - [*homework2*](https://github.com/karcan/javaBootcamp/tree/master/lecture6.2-homework2)
23 | - **Lecture 7**
24 | - [*swaggerAndResult*](https://github.com/karcan/javaBootcamp/tree/master/lecture7.1-swaggerAndResult/src/main/java/kodlamaio/northwind)
25 | - **Lecture 8**
26 | - [*springJPA*](https://github.com/karcan/javaBootcamp/tree/master/lecture8.1-springJPA/src/main/java/kodlamaio/northwind)
27 |
--------------------------------------------------------------------------------
/images/github-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/images/github-32.png
--------------------------------------------------------------------------------
/images/java-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/images/java-32.png
--------------------------------------------------------------------------------
/images/postgresql-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/images/postgresql-32.png
--------------------------------------------------------------------------------
/lecture1-intro/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture1-intro/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture1-intro
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture1-intro/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture1-intro/bin/intro/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture1-intro/bin/intro/Main.class
--------------------------------------------------------------------------------
/lecture1-intro/src/intro/Main.java:
--------------------------------------------------------------------------------
1 | package intro;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 |
7 | // don't repeat yourself
8 | String enterText = "İnternet şubeye gir.";
9 | double yesterdayDollar = 8.15;
10 | double todayDollar = 8.18;
11 | int expiry = 36;
12 | boolean status = true;
13 |
14 | System.out.println(enterText);
15 |
16 | if (todayDollar < yesterdayDollar) {
17 | System.out.println("Dolar düştü.");
18 | }else if (todayDollar > yesterdayDollar) {
19 | System.out.println("Dolar yükseldi.");
20 | }else {
21 | System.out.println("Dolar aaynı..");
22 | }
23 |
24 | String[] credits = {
25 | "Hızlı kredi",
26 | "Mutlu emekli kredisi",
27 | "Konut kredisi",
28 | "Çiftçi kredisi",
29 | "Msb kredisi",
30 | "Meb kredisi"
31 | };
32 |
33 | for (String item : credits) {
34 | System.out.println(item);
35 | }
36 |
37 |
38 | int number1 = 10;
39 | int number2 = 20;
40 | number1 = number2;
41 | number2 = 100;
42 | System.out.println(number1);
43 |
44 | int[] numbers1 = {1,2,3,4,5};
45 | int[] numbers2 = {10,20,30,40,50};
46 | numbers1 = numbers2;
47 | numbers2[0] = 100;
48 | System.out.println(numbers1[0]);
49 |
50 | String city1 = "Ankara";
51 | String city2 = "İstanbul";
52 | city1 = city2;
53 | city2 = "İzmir";
54 | System.out.println(city1);
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture2.1-oopIntro
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/bin/.gitignore:
--------------------------------------------------------------------------------
1 | /oopIntro/
2 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/bin/oopIntro/Category.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture2-oopIntro/bin/oopIntro/Category.class
--------------------------------------------------------------------------------
/lecture2-oopIntro/bin/oopIntro/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture2-oopIntro/bin/oopIntro/Main.class
--------------------------------------------------------------------------------
/lecture2-oopIntro/bin/oopIntro/Product.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture2-oopIntro/bin/oopIntro/Product.class
--------------------------------------------------------------------------------
/lecture2-oopIntro/bin/oopIntro/ProductService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture2-oopIntro/bin/oopIntro/ProductService.class
--------------------------------------------------------------------------------
/lecture2-oopIntro/src/oopIntro/Category.java:
--------------------------------------------------------------------------------
1 | package oopIntro;
2 |
3 | public class Category {
4 | int id;
5 | String name;
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/src/oopIntro/Main.java:
--------------------------------------------------------------------------------
1 | package oopIntro;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 |
7 | Product product1 = new Product(1, "Lenovo V15 IIL",
8 | "Intel Core i3 1005G1 8GB 256GB SSD Windows 10 Home 15.6\" FHD", 4.399);
9 |
10 | Product product2 = new Product(2, "Lenovo IdeaPad",
11 | "AMD Ryzen 7 5700U 8GB 512GB SSD Freedos 14\" FHD Taşınabilir", 5.399);
12 |
13 | Product product3 = new Product(3, "Lenovo V14 IGL",
14 | "Intel Celeron N4020 8GB 256GB SSD Windows 10 Home 14\" FHD", 6.399);
15 |
16 | Product[] products = { product1, product2, product3 };
17 |
18 | for (Product product : products) {
19 | System.out.println(product.name);
20 | }
21 |
22 | Category category1 = new Category();
23 | category1.id = 1;
24 | category1.name = "Bilgisayar";
25 |
26 |
27 | ProductService productService = new ProductService();
28 |
29 | //productService.addToCart(product1);
30 |
31 | productService.addToCart(products);
32 |
33 |
34 | }
35 |
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/src/oopIntro/Product.java:
--------------------------------------------------------------------------------
1 | package oopIntro;
2 |
3 | public class Product {
4 |
5 | public Product() {
6 |
7 | }
8 |
9 | public Product(int id, String name, String shortDescription, double unitPrice) {
10 | this.id = id;
11 | this.name = name;
12 | this.shortDescription = shortDescription;
13 | this.unitPrice = unitPrice;
14 | }
15 |
16 | int id;
17 | String name;
18 | String shortDescription;
19 | double unitPrice;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/lecture2-oopIntro/src/oopIntro/ProductService.java:
--------------------------------------------------------------------------------
1 | package oopIntro;
2 |
3 | public class ProductService {
4 |
5 | public void addToCart(Product product) {
6 | System.out.println("-- (" + product.name + ") sepete eklenmiştir. --");
7 | }
8 |
9 | public void addToCart(Product[] products) {
10 | for (Product product : products) {
11 | this.addToCart(product);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture2.2-homework/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture2.2-homework/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture2.2-homework/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture2.2-homework
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture2.2-homework/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/constant/Message.java:
--------------------------------------------------------------------------------
1 | package homework.constant;
2 |
3 | public class Message {
4 | public static String Added = "added.";
5 | public static String Updated = "updated.";
6 | public static String Deleted = "deleted.";
7 |
8 | public static String limitExceeded = "limit exceeded.";
9 | public static String canNotBeNull = "cannot be null";
10 | public static String canNotBeEmpty = "cannot be empty";
11 | public static String canNotBeNullOrEmpty = "cannot be null or empty";
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/constant/Validation.java:
--------------------------------------------------------------------------------
1 | package homework.constant;
2 |
3 | public class Validation {
4 |
5 | public static String nameLengthExceeded = "character " + Message.limitExceeded;
6 | public static String startDateAndEndDateCanNotBeNull = "startDate and endDate " + Message.canNotBeNull;
7 | }
8 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/dto/CourseDto.java:
--------------------------------------------------------------------------------
1 | package homework.dto;
2 |
3 | public class CourseDto {
4 |
5 | public CourseDto(int id, String courseName, String instructorName, String categoryName) {
6 | this.id = id;
7 | this.courseName = courseName;
8 | this.instructorName = instructorName;
9 | this.categoryName = categoryName;
10 | }
11 |
12 | private final int id;
13 | private final String courseName;
14 | private final String instructorName;
15 | private final String categoryName;
16 |
17 | public int getId() {
18 | return id;
19 | }
20 | public String getCourseName() {
21 | return courseName;
22 | }
23 | public String getInstructorName() {
24 | return instructorName;
25 | }
26 | public String getCategoryName() {
27 | return categoryName;
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/dto/LectureDto.java:
--------------------------------------------------------------------------------
1 | package homework.dto;
2 |
3 | import java.util.Date;
4 |
5 | public class LectureDto {
6 |
7 | public LectureDto(int id, String courseName, String lectureName, Date lectureDate) {
8 | this.id = id;
9 | this.courseName = courseName;
10 | this.lectureName = lectureName;
11 | this.lectureDate = lectureDate;
12 | }
13 |
14 | private final int id;
15 | private final String courseName;
16 | private final String lectureName;
17 | private final Date lectureDate;
18 |
19 | public int getId() {
20 | return id;
21 | }
22 | public String getCourseName() {
23 | return courseName;
24 | }
25 | public String getLectureName() {
26 | return lectureName;
27 | }
28 | public Date getLectureDate() {
29 | return lectureDate;
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/Category.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class Category {
4 |
5 | private int id;
6 | private String name;
7 |
8 | public Category() {}
9 |
10 | public Category(int id, String name) {
11 | this.setId(id);
12 | this.setName(name);
13 | }
14 |
15 | public int getId() {
16 | return id;
17 | }
18 |
19 | public void setId(int id) {
20 | this.id = id;
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/CourseParticipant.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | import java.util.Date;
4 |
5 | public class CourseParticipant {
6 |
7 | private int id;
8 | private int courseId;
9 | private int studentId;
10 | private Date date;
11 |
12 | public CourseParticipant() {}
13 |
14 | public CourseParticipant(int id, int courseId, int studentId, Date date) {
15 | this.setId(id);
16 | this.setCourseId(courseId);
17 | this.setStudentId(studentId);
18 | this.setDate(date);
19 | }
20 |
21 | public int getId() {
22 | return id;
23 | }
24 |
25 | public void setId(int id) {
26 | this.id = id;
27 | }
28 |
29 | public int getCourseId() {
30 | return courseId;
31 | }
32 |
33 | public void setCourseId(int courseId) {
34 | this.courseId = courseId;
35 | }
36 |
37 | public int getStudentId() {
38 | return studentId;
39 | }
40 |
41 | public void setStudentId(int studentId) {
42 | this.studentId = studentId;
43 | }
44 |
45 | public Date getDate() {
46 | return date;
47 | }
48 |
49 | public void setDate(Date date) {
50 | this.date = date;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/Instructor.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class Instructor extends User {
4 |
5 | private String about;
6 |
7 | public Instructor() {}
8 |
9 | public Instructor(int id, String name, String surname, String mail, String username, String password, String about) {
10 | super(id, name, surname, mail, username, password);
11 | this.setAbout(about);
12 | }
13 |
14 | public String getAbout() {
15 | return about;
16 | }
17 |
18 | public void setAbout(String about) {
19 | this.about = about;
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/InstructorNotificationOption.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class InstructorNotificationOption extends UserNotificationOption {
4 |
5 | private boolean commentsMyLectures;
6 |
7 | public InstructorNotificationOption() {}
8 |
9 | public InstructorNotificationOption(int id, boolean myCommentsReplied, boolean commentsWhereIComment, boolean informationAndPromotion, boolean commentsMyLectures) {
10 | super(id, myCommentsReplied, commentsWhereIComment, informationAndPromotion);
11 | this.setCommentsMyLectures(commentsMyLectures);
12 | }
13 |
14 | public boolean isCommentsMyLectures() {
15 | return commentsMyLectures;
16 | }
17 |
18 | public void setCommentsMyLectures(boolean commentsMyLectures) {
19 | this.commentsMyLectures = commentsMyLectures;
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/Lecture.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | import java.util.Date;
4 |
5 | public class Lecture {
6 |
7 | private int id;
8 | private int courseId;
9 | private String name;
10 | private String description;
11 | private Date date;
12 |
13 | public Lecture() {}
14 |
15 | public Lecture(int id, int courseId, String name, String description, Date date) {
16 | this.setId(id);
17 | this.setCourseId(courseId);
18 | this.setName(name);
19 | this.setDescription(description);
20 | this.setDate(date);
21 | }
22 |
23 | public int getId() {
24 | return id;
25 | }
26 |
27 |
28 | public void setId(int id) {
29 | this.id = id;
30 | }
31 |
32 | public int getCourseId() {
33 | return courseId;
34 | }
35 |
36 | public void setCourseId(int courseId) {
37 | this.courseId = courseId;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getDescription() {
49 | return description;
50 | }
51 |
52 | public void setDescription(String description) {
53 | this.description = description;
54 | }
55 |
56 | public Date getDate() {
57 | return date;
58 | }
59 |
60 | public void setDate(Date date) {
61 | this.date = date;
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/LectureComment.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | import java.util.Date;
4 |
5 | public class LectureComment {
6 |
7 | private int id;
8 | private int lectureId;
9 | private int userId;
10 | private Date date;
11 | private Integer parentId;
12 |
13 | public LectureComment() {}
14 |
15 | public LectureComment(int id, int lectureId, int userId, Date date, Integer parentId) {
16 | this.setId(id);
17 | this.setLectureId(lectureId);
18 | this.setUserId(userId);
19 | this.setDate(date);
20 | this.setParentId(parentId);
21 | }
22 |
23 | public int getId() {
24 | return id;
25 | }
26 |
27 | public void setId(int id) {
28 | this.id = id;
29 | }
30 |
31 | public int getLectureId() {
32 | return lectureId;
33 | }
34 |
35 | public void setLectureId(int lectureId) {
36 | this.lectureId = lectureId;
37 | }
38 |
39 | public int getUserId() {
40 | return userId;
41 | }
42 |
43 | public void setUserId(int userId) {
44 | this.userId = userId;
45 | }
46 |
47 | public Date getDate() {
48 | return date;
49 | }
50 |
51 | public void setDate(Date date) {
52 | this.date = date;
53 | }
54 |
55 | public Integer getParentId() {
56 | return parentId;
57 | }
58 |
59 | public void setParentId(Integer parentId) {
60 | this.parentId = parentId;
61 | }
62 |
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/State.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class State {
4 |
5 | private int id;
6 | private String name;
7 |
8 | public State() {}
9 |
10 | public State(int id, String name) {
11 | this.setId(id);
12 | this.setName(name);
13 | }
14 |
15 | public int getId() {
16 | return id;
17 | }
18 |
19 | public void setId(int id) {
20 | this.id = id;
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/Student.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class Student extends User {
4 |
5 | public Student() {}
6 |
7 | public Student(int id, String name, String surname, String mail, String username, String password) {
8 | super(id, name, surname, mail, username, password);
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/User.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class User {
4 |
5 | private int id;
6 | private String name;
7 | private String surname;
8 | private String mail;
9 | private String username;
10 | private String password;
11 |
12 | public User() {}
13 |
14 | public User(int id, String name, String surname, String mail, String username, String password) {
15 | this.setId(id);
16 | this.setName(name);
17 | this.setSurname(surname);
18 | this.setMail(mail);
19 | this.setUsername(username);
20 | this.setPassword(password);
21 | }
22 |
23 |
24 | public int getId() {
25 | return id;
26 | }
27 |
28 | public void setId(int id) {
29 | this.id = id;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 |
40 | public String getSurname() {
41 | return surname;
42 | }
43 |
44 | public void setSurname(String surname) {
45 | this.surname = surname;
46 | }
47 |
48 | public String getMail() {
49 | return mail;
50 | }
51 |
52 | public void setMail(String mail) {
53 | this.mail = mail;
54 | }
55 |
56 | public String getUsername() {
57 | return username;
58 | }
59 |
60 | public void setUsername(String username) {
61 | this.username = username;
62 | }
63 |
64 | public String getPassword() {
65 | return password;
66 | }
67 |
68 | public void setPassword(String password) {
69 | this.password = password;
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/UserAddress.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class UserAddress {
4 |
5 | private int id;
6 | private int userId;
7 | private int countryId;
8 | private String street1;
9 | private String street2;
10 | private String city;
11 | private int stateId;
12 | private String zipCode;
13 |
14 | public UserAddress() {}
15 |
16 | public UserAddress(int id, int userId, int countryId, String street1, String street2, String city, int stateId, String zipCode) {
17 | this.setId(id);
18 | this.setUserId(userId);
19 | this.setCountryId(countryId);
20 | this.setStreet1(street1);
21 | this.setStreet2(street2);
22 | this.setCity(city);
23 | this.setStateId(stateId);
24 | this.setZipCode(zipCode);
25 | }
26 |
27 | public int getId() {
28 | return id;
29 | }
30 |
31 | public void setId(int id) {
32 | this.id = id;
33 | }
34 |
35 | public int getUserId() {
36 | return userId;
37 | }
38 |
39 | public void setUserId(int userId) {
40 | this.userId = userId;
41 | }
42 |
43 | public int getCountryId() {
44 | return countryId;
45 | }
46 |
47 | public void setCountryId(int countryId) {
48 | this.countryId = countryId;
49 | }
50 |
51 | public String getStreet1() {
52 | return street1;
53 | }
54 |
55 | public void setStreet1(String street1) {
56 | this.street1 = street1;
57 | }
58 |
59 | public String getStreet2() {
60 | return street2;
61 | }
62 |
63 | public void setStreet2(String street2) {
64 | this.street2 = street2;
65 | }
66 |
67 | public String getCity() {
68 | return city;
69 | }
70 |
71 | public void setCity(String city) {
72 | this.city = city;
73 | }
74 |
75 | public int getStateId() {
76 | return stateId;
77 | }
78 |
79 | public void setStateId(int stateId) {
80 | this.stateId = stateId;
81 | }
82 |
83 | public String getZipCode() {
84 | return zipCode;
85 | }
86 |
87 | public void setZipCode(String zipCode) {
88 | this.zipCode = zipCode;
89 | }
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/model/UserNotificationOption.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class UserNotificationOption {
4 |
5 | private int id;
6 | private boolean myCommentsReplied;
7 | private boolean commentsWhereIComment;
8 | private boolean informationAndPromotion;
9 |
10 | public UserNotificationOption() {}
11 |
12 | public UserNotificationOption(int id, boolean myCommentsReplied, boolean commentsWhereIComment, boolean informationAndPromotion) {
13 | this.setId(id);
14 | this.setMyCommentsReplied(myCommentsReplied);
15 | this.setCommentsWhereIComment(commentsWhereIComment);
16 | this.setInformationAndPromotion(informationAndPromotion);
17 | }
18 |
19 | public int getId() {
20 | return id;
21 | }
22 |
23 | public void setId(int id) {
24 | this.id = id;
25 | }
26 |
27 | public boolean isMyCommentsReplied() {
28 | return myCommentsReplied;
29 | }
30 |
31 | public void setMyCommentsReplied(boolean myCommentsReplied) {
32 | this.myCommentsReplied = myCommentsReplied;
33 | }
34 |
35 | public boolean isCommentsWhereIComment() {
36 | return commentsWhereIComment;
37 | }
38 |
39 | public void setCommentsWhereIComment(boolean commentsWhereIComment) {
40 | this.commentsWhereIComment = commentsWhereIComment;
41 | }
42 |
43 | public boolean isInformationAndPromotion() {
44 | return informationAndPromotion;
45 | }
46 |
47 | public void setInformationAndPromotion(boolean informationAndPromotion) {
48 | this.informationAndPromotion = informationAndPromotion;
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/service/CategoryService.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import homework.constant.Message;
7 | import homework.model.Category;
8 |
9 | public class CategoryService {
10 |
11 | List _categories;
12 |
13 | public CategoryService() {
14 | this._categories = new ArrayList();
15 |
16 | this._categories.add(new Category(1,"Java"));
17 | this._categories.add(new Category(2,"C#"));
18 |
19 | }
20 |
21 | public void add(Category category) {
22 |
23 | this._categories.add(category);
24 | System.out.println(category.getName() + " " + Message.Added);
25 | }
26 |
27 | public void update(Category category) {
28 |
29 | int courseIndex = this._categories.indexOf(category);
30 |
31 | this._categories.set(courseIndex, category);
32 | System.out.println(category.getName() + " " + Message.Updated);
33 | }
34 |
35 | public void delete(Category category) {
36 |
37 | int courseIndex = this._categories.indexOf(category);
38 |
39 | this._categories.remove(courseIndex);
40 | System.out.println(category.getName() + " " + Message.Deleted);
41 | }
42 |
43 | public Category getById(int id) {
44 | return this._categories.stream().filter(c -> c.getId() == id).findFirst().get();
45 | }
46 |
47 | public List getAll() {
48 | return _categories;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/service/InstructorService.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import homework.constant.Message;
7 | import homework.model.Instructor;
8 |
9 | public class InstructorService {
10 |
11 | private List _instructors;
12 |
13 | public InstructorService() {
14 | this._instructors = new ArrayList();
15 |
16 | this._instructors.add(new Instructor(1, "Engin", "Demiroğ", "", "", "", ""));
17 | }
18 |
19 | public void add(Instructor instructor) {
20 |
21 | this._instructors.add(instructor);
22 | System.out.println(instructor.getName() + " " + Message.Added);
23 | }
24 |
25 | public void update(Instructor instructor) {
26 |
27 | int instructorIndex = this._instructors.indexOf(instructor);
28 |
29 | this._instructors.set(instructorIndex, instructor);
30 | System.out.println(instructor.getName() + " " + Message.Updated);
31 | }
32 |
33 | public void delete(Instructor instructor) {
34 |
35 | int instructorIndex = this._instructors.indexOf(instructor);
36 |
37 | this._instructors.remove(instructorIndex);
38 | System.out.println(instructor.getName() + " " + Message.Updated);
39 | }
40 |
41 | public Instructor getById(int id) {
42 | return this._instructors.stream().filter(u -> u.getId() == id).findFirst().get();
43 | }
44 |
45 | public List getAll() {
46 | return this._instructors;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/service/LectureService.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.stream.Collectors;
6 |
7 | import homework.constant.Message;
8 | import homework.dto.LectureDto;
9 | import homework.model.Course;
10 | import homework.model.Lecture;
11 |
12 | public class LectureService {
13 |
14 | private List _lectures;
15 | private CourseService _courseService;
16 |
17 | public LectureService() {
18 | this._lectures = new ArrayList();
19 | this._courseService = new CourseService();
20 | }
21 |
22 | public void add(Lecture lecture) {
23 |
24 | this._lectures.add(lecture);
25 | System.out.println(lecture.getName() + " " + Message.Added);
26 | }
27 |
28 | public void add(Lecture[] lectures) {
29 | for (Lecture lecture : lectures) {
30 | this.add(lecture);
31 | }
32 | }
33 |
34 | public void update(Lecture lecture) {
35 |
36 | int lectureIndex = this._lectures.indexOf(lecture);
37 |
38 | this._lectures.set(lectureIndex, lecture);
39 | System.out.println(lecture.getName() + " " + Message.Updated);
40 | }
41 |
42 | public void delete(Lecture lecture) {
43 |
44 | int lectureIndex = this._lectures.indexOf(lecture);
45 |
46 | this._lectures.remove(lectureIndex);
47 | System.out.println(lecture.getName() + " " + Message.Deleted);
48 | }
49 |
50 | public List getLectureDto() {
51 | return _lectures.stream().map(l -> {
52 | Course course = this._courseService.getById(l.getCourseId());
53 | return new LectureDto(
54 | l.getId(),
55 | course.getName(),
56 | l.getName(),
57 | l.getDate()
58 | );
59 | }).collect(Collectors.toList());
60 | }
61 |
62 | public Lecture getById(int id) {
63 | return _lectures.stream().filter(l -> l.getId() == id).findFirst().get();
64 | }
65 |
66 | public List getAll() {
67 | return _lectures;
68 | }
69 |
70 | public List getAllByCourseId(int courseId) {
71 | return _lectures.stream().filter(l -> l.getCourseId() == courseId).collect(Collectors.toList());
72 | }
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/service/StudentService.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import homework.constant.Message;
7 | import homework.constant.Validation;
8 | import homework.model.Student;
9 |
10 | public class StudentService {
11 |
12 | private List _students;
13 |
14 | public StudentService() {
15 | this._students = new ArrayList();
16 | }
17 |
18 | public void add(Student student) {
19 |
20 | if(!this.checkNameLength(student)) {
21 | System.out.println("\"" + student.getName() + "\" " + Validation.nameLengthExceeded);
22 | return;
23 | }
24 |
25 | this._students.add(student);
26 | System.out.println(student.getName() + " " + Message.Added);
27 | }
28 |
29 | public void add(Student[] students) {
30 | for (Student student : students) {
31 | this.add(student);
32 | }
33 | }
34 |
35 | public void update(Student student) {
36 |
37 | if(!this.checkNameLength(student)) {
38 | System.out.println("\"" + student.getName() + "\" " + Validation.nameLengthExceeded);
39 | return;
40 | }
41 |
42 | int userIndex = this._students.indexOf(student);
43 |
44 | this._students.set(userIndex, student);
45 | System.out.println(student.getName() + " " + Message.Updated);
46 | }
47 |
48 | public void delete (Student student) {
49 |
50 | int userIndex = this._students.indexOf(student);
51 |
52 | this._students.remove(userIndex);
53 | System.out.println(student.getName() + " " + Message.Deleted);
54 | }
55 |
56 | public Student getById (int id) {
57 |
58 | return _students.stream().filter(u -> u.getId() == id).findFirst().get();
59 | }
60 |
61 | public List getAll(){
62 |
63 | return _students;
64 | }
65 |
66 | private boolean checkNameLength(Student user) {
67 |
68 | if(user.getName().length() > 25) {
69 | return false;
70 | }
71 |
72 | return true;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/lecture2.2-homework/src/homework/service/UserService.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import homework.constant.Message;
7 | import homework.constant.Validation;
8 | import homework.model.User;
9 |
10 | public class UserService {
11 |
12 | private List _users;
13 |
14 | public UserService() {
15 | this._users = new ArrayList();
16 | }
17 |
18 | public void add(User user) {
19 |
20 | if(!this.checkNameLength(user)) {
21 | System.out.println("\"" + user.getName() + "\" " + Validation.nameLengthExceeded);
22 | return;
23 | }
24 |
25 | this._users.add(user);
26 | System.out.println(user.getName() + " " + Message.Added);
27 | }
28 |
29 | public void add(User[] users) {
30 | for (User user : users) {
31 | this.add(user);
32 | }
33 | }
34 |
35 | public void update(User user) {
36 |
37 | if(!this.checkNameLength(user)) {
38 | System.out.println("\"" + user.getName() + "\" " + Validation.nameLengthExceeded);
39 | return;
40 | }
41 |
42 | int userIndex = this._users.indexOf(user);
43 |
44 | this._users.set(userIndex, user);
45 | System.out.println(user.getName() + " " + Message.Updated);
46 | }
47 |
48 | public void delete(User user) {
49 |
50 | int userIndex = this._users.indexOf(user);
51 |
52 | this._users.remove(userIndex);
53 | System.out.println(user.getName() + " " + Message.Deleted);
54 | }
55 |
56 | public User getById(int id) {
57 |
58 | return _users.stream().filter(u -> u.getId() == id).findFirst().get();
59 | }
60 |
61 | public List getAll() {
62 | return _users;
63 | }
64 |
65 | private boolean checkNameLength(User user) {
66 |
67 | if(user.getName().length() > 25) {
68 | return false;
69 | }
70 |
71 | return true;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture3.1-oopIntro2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/src/oopIntro2/Category.java:
--------------------------------------------------------------------------------
1 | package oopIntro2;
2 |
3 | public class Category {
4 |
5 | private int id;
6 | private String name;
7 |
8 | public Category() {
9 |
10 | }
11 |
12 | public Category(int id, String name) {
13 | super();
14 | this.id = id;
15 | this.name = name;
16 | }
17 |
18 | public int getId() {
19 | return id;
20 | }
21 | public void setId(int id) {
22 | this.id = id;
23 | }
24 | public String getName() {
25 | return name+"!";
26 | }
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/src/oopIntro2/Main.java:
--------------------------------------------------------------------------------
1 | package oopIntro2;
2 |
3 |
4 | public class Main {
5 |
6 | public static void main(String[] args) {
7 |
8 | Product product1 = new Product(1, "Lenovo V14", 15000, "16 GB Ram",10);
9 | System.out.println(product1.getName());
10 |
11 | Product product2 = new Product();
12 | product2.setId(2);
13 | product2.setName("Lenovo V15");
14 | product2.setDetail("16 Gb Ram");
15 | product2.setDiscount(10);
16 | product2.setUnitPrice(16000);
17 |
18 | System.out.println(product2.getUnitPriceAfterDiscount());
19 |
20 | Category category1 = new Category();
21 | category1.setId(1);
22 | category1.setName("İçecek");
23 |
24 | Category category2 = new Category();
25 | category2.setId(2);
26 | category2.setName("Yiyecek");
27 |
28 | System.out.println(category1.getName());
29 | System.out.println(category2.getName());
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/src/oopIntro2/Product.java:
--------------------------------------------------------------------------------
1 | package oopIntro2;
2 |
3 | public class Product {
4 |
5 | //encapsulation
6 | private int id;
7 | private String name;
8 | private double unitPrice;
9 | private String detail;
10 | private double discount;
11 |
12 | public Product() {
13 |
14 | }
15 |
16 | public Product(int id, String name, double unitPrice, String detail, double discount) {
17 | super();
18 | this.id = id;
19 | this.name = name;
20 | this.unitPrice = unitPrice;
21 | this.detail = detail;
22 | this.discount = discount;
23 | }
24 |
25 | public int getId() {
26 | return id;
27 | }
28 |
29 | public void setId(int id) {
30 | this.id = id;
31 | }
32 |
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 |
41 | public double getUnitPrice() {
42 | return unitPrice;
43 | }
44 |
45 | public void setUnitPrice(double unitPrice) {
46 | this.unitPrice = unitPrice;
47 | }
48 |
49 | public String getDetail() {
50 | return detail;
51 | }
52 |
53 | public void setDetail(String detail) {
54 | this.detail = detail;
55 | }
56 |
57 | public double getDiscount() {
58 | return discount;
59 | }
60 |
61 | public void setDiscount(double discount) {
62 | this.discount = discount;
63 | }
64 |
65 | public double getUnitPriceAfterDiscount() {
66 | return unitPrice - (unitPrice * discount / 100);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/lecture3.1-oopIntro2/src/oopIntro2/ProductManager.java:
--------------------------------------------------------------------------------
1 | package oopIntro2;
2 |
3 | public class ProductManager {
4 | public void addToCart(Product product) {
5 | System.out.println("Sepete eklendi :" + product.getName());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture3.2-inheritance
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/CorporateCustomer.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class CorporateCustomer extends Customer {
4 | private String companyName;
5 | private String taxNumber;
6 |
7 | public CorporateCustomer() {
8 | }
9 |
10 | public CorporateCustomer (int id, String customerNumber, String companyName, String taxNumber){
11 | super(id,customerNumber);
12 | this.companyName = companyName;
13 | this.taxNumber = taxNumber;
14 | }
15 |
16 | public String getCompanyName() {
17 | return companyName;
18 | }
19 |
20 | public void setCompanyName(String companyName) {
21 | this.companyName = companyName;
22 | }
23 |
24 | public String getTaxNumber() {
25 | return taxNumber;
26 | }
27 |
28 | public void setTaxNumber(String taxNumber) {
29 | this.taxNumber = taxNumber;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/Customer.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class Customer {
4 | private int id;
5 | private String customerNumber;
6 |
7 | public Customer() {
8 |
9 | }
10 |
11 | public Customer(int id, String customerNumber) {
12 | this.id = id;
13 | this.customerNumber = customerNumber;
14 | }
15 |
16 | public int getId() {
17 | return id;
18 | }
19 |
20 | public void setId(int id) {
21 | this.id = id;
22 | }
23 |
24 | public String getCustomerNumber() {
25 | return customerNumber;
26 | }
27 |
28 | public void setCustomerNumber(String customerNumber) {
29 | this.customerNumber = customerNumber;
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/CustomerManager.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class CustomerManager {
4 | public void add(Customer customer) {
5 | System.out.println(customer.getCustomerNumber() + " kaydedildi.");
6 | }
7 |
8 | //bulk insert
9 | public void addMultiple(Customer[] customers) {
10 | for (Customer customer : customers) {
11 | this.add(customer);
12 | }
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/IndividualCustomer.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class IndividualCustomer extends Customer {
4 |
5 | private String firstName;
6 | private String lastName;
7 | private String nationalIdentity;
8 |
9 | public IndividualCustomer() {
10 |
11 | }
12 |
13 | public IndividualCustomer(int id, String customerNumber, String firstName, String lastName, String nationalIdentity) {
14 | super(id,customerNumber);
15 | this.firstName = firstName;
16 | this.lastName = lastName;
17 | this.nationalIdentity = nationalIdentity;
18 | }
19 |
20 | public String getFirstName() {
21 | return firstName;
22 | }
23 |
24 | public void setFirstName(String firstName) {
25 | this.firstName = firstName;
26 | }
27 |
28 | public String getLastName() {
29 | return lastName;
30 | }
31 |
32 | public void setLastName(String lastName) {
33 | this.lastName = lastName;
34 | }
35 |
36 | public String getNationalIdentity() {
37 | return nationalIdentity;
38 | }
39 |
40 | public void setNationalIdentity(String nationalIdentity) {
41 | this.nationalIdentity = nationalIdentity;
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/Main.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | IndividualCustomer engin = new IndividualCustomer();
7 | engin.setCustomerNumber("12345");
8 |
9 | CorporateCustomer hepsiBurada = new CorporateCustomer();
10 | hepsiBurada.setCustomerNumber("78910");
11 |
12 | SyndicateCustomer syndicateCustomer = new SyndicateCustomer();
13 | syndicateCustomer.setCustomerNumber("99999");
14 |
15 | CustomerManager customerManager = new CustomerManager();
16 | customerManager.addMultiple(new Customer[] {engin,hepsiBurada,syndicateCustomer});
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lecture3.2-inheritance/src/inheritance/SyndicateCustomer.java:
--------------------------------------------------------------------------------
1 | package inheritance;
2 |
3 | public class SyndicateCustomer extends Customer{
4 | String syndicateThing;
5 | }
6 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture3.3-inheritance2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/CustomerManager.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class CustomerManager {
4 |
5 | public void add(Logger logger) {
6 | //müşteri ekleme kodları
7 | System.out.println("Müşteri eklendi");
8 | logger.log();
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/DatabaseLogger.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class DatabaseLogger extends Logger{
4 | @Override
5 | public void log() {
6 | System.out.println("Database loglandı");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/EmailLogger.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class EmailLogger extends Logger{
4 | @Override
5 | public void log() {
6 | System.out.println("Email yollandı");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/FileLogger.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class FileLogger extends Logger {
4 | @Override
5 | public void log() {
6 | System.out.println("Dosyaya loglandı");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/LogManager.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class LogManager {
4 | public void log(Logger logger) {
5 | logger.log();
6 | }
7 | }
8 |
9 |
10 | //1 - Database
11 | //2 - File
12 | //3 - Email
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/Logger.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class Logger {
4 | public void log() {
5 | System.out.println("Ortak konfigurasyon");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/lecture3.3-inheritance2/src/inheritance2/Main.java:
--------------------------------------------------------------------------------
1 | package inheritance2;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 |
7 | CustomerManager customerManager = new CustomerManager();
8 | customerManager.add(new EmailLogger());
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/lecture3.4-homework/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture3.4-homework/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture3.4-homework/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture3.4-homework
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture3.4-homework/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/Main.java:
--------------------------------------------------------------------------------
1 | package homework;
2 |
3 | import homework.model.Instructor;
4 | import homework.model.Student;
5 | import homework.service.InstructorManager;
6 | import homework.service.StudentManager;
7 |
8 | public class Main {
9 |
10 | public static void main(String[] args) {
11 |
12 | System.out.println("---- Student ----");
13 | Student student = new Student(1,"Ahmet","Mehmet","email","u","password","avatar.jpg");
14 | StudentManager studentManager = new StudentManager();
15 | studentManager.add(student);
16 |
17 | System.out.println("\n---- Student Courses ----");
18 | studentManager.getCourses(0);
19 |
20 | System.out.println("\n---- Instructor ----");
21 | Instructor instructor = new Instructor(2,"Engin","Demiroğ","engindemirog@gmail.com","avatar.jpg","engin","demirog");
22 | InstructorManager instructorManager = new InstructorManager();
23 | instructorManager.add(instructor);
24 |
25 | System.out.println("\n---- Instructor Courses ----");
26 | instructorManager.getCourses(0);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/model/Instructor.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class Instructor extends User {
4 |
5 | private String preface;
6 | private String about;
7 |
8 | public Instructor() {
9 |
10 | }
11 |
12 | public Instructor(int id, String firstName, String lastName, String email, String username, String password, String avatarUrl) {
13 | super(id, firstName, lastName, email, username, password, avatarUrl);
14 | }
15 |
16 | public Instructor(int id, String firstName, String lastName, String email, String username, String password, String avatarUrl, String preface, String about) {
17 | this(id, firstName, lastName, email, username, password, avatarUrl);
18 | this.setPreface(preface);
19 | this.setAbout(about);
20 | }
21 |
22 | public String getPreface() {
23 | return preface;
24 | }
25 |
26 | public void setPreface(String preface) {
27 | this.preface = preface;
28 | }
29 |
30 | public String getAbout() {
31 | return about;
32 | }
33 |
34 | public void setAbout(String about) {
35 | this.about = about;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/model/Student.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class Student extends User{
4 |
5 | public Student() {
6 |
7 | }
8 |
9 | public Student(int id, String firstName, String lastName, String email, String username, String password, String avatarUrl) {
10 | super(id, firstName, lastName, email, username, password, avatarUrl);
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/model/User.java:
--------------------------------------------------------------------------------
1 | package homework.model;
2 |
3 | public class User {
4 | private int id;
5 | private String firstName;
6 | private String lastName;
7 | private String email;
8 | private String username;
9 | private String password;
10 | private String avatarUrl;
11 |
12 | public User() {}
13 |
14 | public User(int id, String firstName, String lastName, String email, String username, String password, String avatarUrl) {
15 | this.id = id;
16 | this.firstName = firstName;
17 | this.lastName = lastName;
18 | this.email = email;
19 | this.username = username;
20 | this.password = password;
21 | this.avatarUrl = avatarUrl;
22 | }
23 |
24 | public int getId() {
25 | return id;
26 | }
27 | public void setId(int id) {
28 | this.id = id;
29 | }
30 | public String getFirstName() {
31 | return firstName;
32 | }
33 | public void setFirstName(String firstName) {
34 | this.firstName = firstName;
35 | }
36 | public String getLastName() {
37 | return lastName;
38 | }
39 | public void setLastName(String lastName) {
40 | this.lastName = lastName;
41 | }
42 | public String getEmail() {
43 | return email;
44 | }
45 | public void setEmail(String email) {
46 | this.email = email;
47 | }
48 | public String getUsername() {
49 | return username;
50 | }
51 | public void setUsername(String username) {
52 | this.username = username;
53 | }
54 | public String getPassword() {
55 | return password;
56 | }
57 | public void setPassword(String password) {
58 | this.password = password;
59 | }
60 |
61 | public String getAvatarUrl() {
62 | return avatarUrl;
63 | }
64 |
65 | public void setAvatarUrl(String avatarUrl) {
66 | this.avatarUrl = avatarUrl;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/service/InstructorManager.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import homework.model.Course;
4 | import homework.model.Instructor;
5 |
6 | public class InstructorManager extends UserManager {
7 |
8 | public void add(Instructor instructor) {
9 | if(!this.requiredFirstName(instructor.getFirstName()) || !this.requiredLastName(instructor.getLastName())) {
10 | return;
11 | }
12 | super.add(instructor);
13 | }
14 |
15 | public void update(Instructor instructor) {
16 | if(!this.requiredFirstName(instructor.getFirstName()) || !this.requiredLastName(instructor.getLastName())) {
17 | return;
18 | }
19 |
20 | super.update(instructor);
21 | }
22 |
23 | @Override
24 | public Course[] getCourses(int instructorId) {
25 | System.out.println("instructor's courses listed.");
26 | return new Course[] {};
27 | }
28 |
29 | private boolean requiredFirstName(String firstName) {
30 | if(firstName == null || firstName.trim().isEmpty()) {
31 | System.out.println("first name cannot be null or empty");
32 | return false;
33 | }
34 |
35 | return true;
36 | }
37 |
38 | private boolean requiredLastName(String lastName) {
39 | if(lastName == null || lastName.trim().isEmpty()) {
40 | System.out.println("last name cannot be null or empty");
41 | return false;
42 | }
43 |
44 | return true;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/service/StudentManager.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import homework.model.Course;
4 | import homework.model.Student;
5 |
6 | public class StudentManager extends UserManager{
7 |
8 |
9 | public void add(Student student) {
10 | if(!this.checkUsernameLength(student)) {
11 | return;
12 | }
13 |
14 | super.add(student);
15 | }
16 |
17 | public void update(Student student) {
18 | if(!this.checkUsernameLength(student)) {
19 | return;
20 | }
21 |
22 | super.update(student);
23 | }
24 |
25 | @Override
26 | public Course[] getCourses(int studentId) {
27 | System.out.println("student's courses listed.");
28 | return new Course[] {};
29 | }
30 |
31 | private boolean checkUsernameLength(Student student) {
32 | if(student.getUsername().length() <= 3) {
33 | System.out.println("username cannot be less then 3 characters.");
34 | return false;
35 | }
36 |
37 | return true;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lecture3.4-homework/src/homework/service/UserManager.java:
--------------------------------------------------------------------------------
1 | package homework.service;
2 |
3 | import homework.model.Course;
4 | import homework.model.User;
5 |
6 | public class UserManager {
7 |
8 | public void add(User user) {
9 |
10 | if(!this.checkEmailCorrect(user)) {
11 | return;
12 | }
13 |
14 | System.out.println(user.getFirstName()+" "+user.getLastName() + " added.");
15 | }
16 |
17 | public void update(User user) {
18 |
19 | if(!this.checkEmailCorrect(user)) {
20 | return;
21 | }
22 |
23 | System.out.println(user.getFirstName()+" "+user.getLastName() + " updated.");
24 | }
25 |
26 | public void delete(User user) {
27 | System.out.println(user.getFirstName()+" "+user.getLastName() + " deleted.");
28 | }
29 |
30 | public Course[] getCourses(int userId) {
31 | System.out.println("user courses listed.");
32 | return new Course[] {};
33 | }
34 |
35 | public User[] getAll() {
36 | System.out.println("all users brought");
37 | return new User[] {};
38 | }
39 |
40 | public User getById(int id) {
41 | System.out.println("user brought");
42 | return new User();
43 | }
44 |
45 | public User[] getByCourseId(int courseId) {
46 | System.out.println("users brought");
47 | return new User[] {};
48 | }
49 |
50 | public User getByMail(String mail) {
51 | System.out.println("user brought");
52 | return new User();
53 | }
54 |
55 | private boolean checkEmailCorrect(User user) {
56 | if(user.getEmail().length() <= 15) {
57 | System.out.println("Mail adress is incorrect.");
58 | return false;
59 | }
60 | return true;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/lecture4.1-interface/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture4.1-interface/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture4.1-interface/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture4.1-interface
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture4.1-interface/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/Customer.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class Customer {
4 | private int id;
5 | private String firstName;
6 | private String lastName;
7 |
8 | public Customer() {
9 |
10 | }
11 |
12 | public Customer(int id, String firstName, String lastName) {
13 | this.id = id;
14 | this.firstName = firstName;
15 | this.lastName = lastName;
16 | }
17 |
18 | public int getId() {
19 | return id;
20 | }
21 |
22 | public void setId(int id) {
23 | this.id = id;
24 | }
25 |
26 | public String getFirstName() {
27 | return firstName;
28 | }
29 |
30 | public void setFirstName(String firstName) {
31 | this.firstName = firstName;
32 | }
33 |
34 | public String getLastName() {
35 | return lastName;
36 | }
37 |
38 | public void setLastName(String lastName) {
39 | this.lastName = lastName;
40 | }
41 |
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/CustomerManager.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class CustomerManager {
4 |
5 | private Logger[] loggers;
6 |
7 | public CustomerManager(Logger[] loggers) {
8 | this.loggers = loggers;
9 | }
10 |
11 | public void add(Customer customer) {
12 | System.out.println("Müşteri eklendi " + customer.getFirstName());
13 | Utils.runLoggers(loggers, customer.getFirstName());
14 | }
15 | public void delete(Customer customer) {
16 | System.out.println("Müşteri silindi " + customer.getFirstName());
17 | Utils.runLoggers(loggers, customer.getFirstName());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/DatabaseLogger.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class DatabaseLogger implements Logger {
4 |
5 | @Override
6 | public void log(String message) {
7 | System.out.println("Database loglandı : " + message);
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/EmailLogger.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class EmailLogger implements Logger{
4 |
5 | @Override
6 | public void log(String message) {
7 | System.out.println("Email loglandı : " + message);
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/FileLogger.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class FileLogger implements Logger {
4 |
5 | @Override
6 | public void log(String message) {
7 | System.out.println("Dosyaya loglandı : " + message);
8 |
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/Logger.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public interface Logger {
4 | void log(String message);
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/Main.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 |
7 | Logger[] loggers = {new SmsLogger(), new EmailLogger()};
8 |
9 | CustomerManager customerManager = new CustomerManager(loggers);
10 |
11 | Customer engin = new Customer(1,"Engin","Demiroğ");
12 |
13 | customerManager.add(engin);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/SmsLogger.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class SmsLogger implements Logger {
4 |
5 | @Override
6 | public void log(String message) {
7 | System.out.println("Sms gönderildi : " + message);
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lecture4.1-interface/src/interfaces/Utils.java:
--------------------------------------------------------------------------------
1 | package interfaces;
2 |
3 | public class Utils {
4 | public static void runLoggers(Logger[] loggers, String message) {
5 | for (Logger logger : loggers) {
6 | logger.log(message);
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture4.2-homework2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jem.workbench.JavaEMFNature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublic.java=UTF-8
3 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicLocator.java=UTF-8
4 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicSoap.java=UTF-8
5 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicSoapStub.java=UTF-8
6 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/README.md:
--------------------------------------------------------------------------------
1 | # MERNİS ( Kimlik Doğrulama Servisi ) Projeye Ekleme
2 |
3 | ### Üst menüden, "File - New - Project"
4 |
5 |
6 | * * *
7 |
8 | ### Wizards: kısmında "Java Project" yazıp, alt taraftan "Java Project" yazanı seçip "Next" butonuna basıyoruz.
9 |
10 |
11 | * * *
12 |
13 | ### Project name "MernisTest" olarak açıyorum, "Use an execution environment JRE:" kısmından JavaSE-1.8 seçiyoruz. (Mernis servisi için stabil sürüm) ve "Finish" diyoruz.
14 |
15 |
16 | * * *
17 |
18 | ### Module name "MernisTest" olarak belirledim. "Don't Create" butonuna basıyorum ve projemi oluşturuyorum.
19 |
20 |
21 | * * *
22 |
23 | ### Oluşan projeme sağ tıklayıp, "New - Other" seçiyorum.
24 |
25 |
26 | * * *
27 |
28 | ### Wizards: kısmına "Web Service Client" yazıp, "Web Services altında ki Web Service Client" olanı seçiyorum ve "Next" butonuna basıyorum.
29 |
30 |
31 | * * *
32 |
33 | ### Service definition: kısmına "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL" adresini yapıştırıyorum ve "Finish" butonuna basıyorum.
34 |
35 |
36 | * * *
37 |
38 | ### Yine projemde "src" klasörüne sağ tıklayarak "New - Class" seçiyorum.
39 |
40 |
41 | * * *
42 |
43 | ### Package: kısmını boş bırakıyorum, Name: kısmına "Main" yazıyorum, [ ] public static void main. yazan kısmı seçiyorum ve "Finish" butonuna basıyorum.
44 |
45 |
46 | * * *
47 |
48 | ### Kırmızı çerçeveye aldığım her şeyi aynı şekilde yazarak projenizi mernis kimlik kontrolü ile birlikte çalıştırabilirsiniz.
49 |
50 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/1.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/10.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/2.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/3.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/4.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/5.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/6.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/7.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/8.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/images/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/images/9.png
--------------------------------------------------------------------------------
/lecture4.2-homework2/libs/activation.jar.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/libs/activation.jar.zip
--------------------------------------------------------------------------------
/lecture4.2-homework2/libs/mail.jar.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture4.2-homework2/libs/mail.jar.zip
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/README.md:
--------------------------------------------------------------------------------
1 | # MERNİS ( Kimlik Doğrulama Servisi ) Projeye Ekleme
2 |
3 | ### Üst menüden, "File - New - Project"
4 |
5 |
6 | * * *
7 |
8 | ### Wizards: kısmında "Java Project" yazıp, alt taraftan "Java Project" yazanı seçip "Next" butonuna basıyoruz.
9 |
10 |
11 | * * *
12 |
13 | ### Project name "MernisTest" olarak açıyorum, "Use an execution environment JRE:" kısmından JavaSE-1.8 seçiyoruz. (Mernis servisi için stabil sürüm) ve "Finish" diyoruz.
14 |
15 |
16 | * * *
17 |
18 | ### Module name "MernisTest" olarak belirledim. "Don't Create" butonuna basıyorum ve projemi oluşturuyorum.
19 |
20 |
21 | * * *
22 |
23 | ### Oluşan projeme sağ tıklayıp, "New - Other" seçiyorum.
24 |
25 |
26 | * * *
27 |
28 | ### Wizards: kısmına "Web Service Client" yazıp, "Web Services altında ki Web Service Client" olanı seçiyorum ve "Next" butonuna basıyorum.
29 |
30 |
31 | * * *
32 |
33 | ### Service definition: kısmına "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL" adresini yapıştırıyorum ve "Finish" butonuna basıyorum.
34 |
35 |
36 | * * *
37 |
38 | ### Yine projemde "src" klasörüne sağ tıklayarak "New - Class" seçiyorum.
39 |
40 |
41 | * * *
42 |
43 | ### Package: kısmını boş bırakıyorum, Name: kısmına "Main" yazıyorum, [ ] public static void main. yazan kısmı seçiyorum ve "Finish" butonuna basıyorum.
44 |
45 |
46 | * * *
47 |
48 | ### Kırmızı çerçeveye aldığım her şeyi aynı şekilde yazarak projenizi mernis kimlik kontrolü ile birlikte çalıştırabilirsiniz.
49 |
50 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/Main.java:
--------------------------------------------------------------------------------
1 | package homework2;
2 |
3 | import java.util.GregorianCalendar;
4 |
5 | import homework2.adapters.MernisServiceAdapter;
6 | import homework2.entities.Customer;
7 | import homework2.interfaces.CustomerCheckService;
8 | import homework2.interfaces.CustomerService;
9 | import homework2.services.StarbucksCustomerCheckManager;
10 | import homework2.services.StarbucksCustomerManager;
11 |
12 | public class Main {
13 |
14 | public static void main(String[] args) {
15 |
16 | Customer enginCustomer = new Customer();
17 | enginCustomer.setId(1);
18 | enginCustomer.setIdentityNumber("000000000000");
19 | enginCustomer.setFirstName("Karcan");
20 | enginCustomer.setLastName("Özbal");
21 | enginCustomer.setBirthDate(new GregorianCalendar(1993, 11 , 16).getTime());
22 |
23 | CustomerCheckService customerCheckService = new StarbucksCustomerCheckManager(new MernisServiceAdapter());
24 |
25 | CustomerService customerService = new StarbucksCustomerManager(customerCheckService);
26 | customerService.add(enginCustomer);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/abstracts/CustomerCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework2.abstracts;
2 |
3 |
4 | import java.time.LocalDate;
5 | import java.time.Period;
6 | import java.time.ZoneId;
7 |
8 |
9 | import homework2.entities.Customer;
10 | import homework2.interfaces.CustomerCheckService;
11 | import homework2.interfaces.Result;
12 |
13 | public abstract class CustomerCheckManager implements CustomerCheckService {
14 |
15 | @Override
16 | public Result CheckIfRealPerson(Customer customer) {
17 |
18 | return new homework2.utils.Result(true);
19 | }
20 |
21 | @Override
22 | public final Result CheckIfYoungerAgeThan(Customer customer, int age) {
23 | LocalDate todayDateTime = LocalDate.now();
24 | LocalDate birthDate = customer.getBirthDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
25 | int yearDifference = Period.between(birthDate, todayDateTime).getYears();
26 | if(yearDifference < age) {
27 | return new homework2.utils.Result(false, age + " yaşından küçük olamaz.");
28 | }
29 | return new homework2.utils.Result(true);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/abstracts/CustomerManager.java:
--------------------------------------------------------------------------------
1 | package homework2.abstracts;
2 |
3 | import homework2.entities.Customer;
4 | import homework2.interfaces.CustomerService;
5 |
6 | public abstract class CustomerManager implements CustomerService {
7 |
8 | @Override
9 | public void add(Customer customer) {
10 | System.out.println(customer.getFirstName() + " başarılı bir şekilde kaydedildi.");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/adapters/MernisServiceAdapter.java:
--------------------------------------------------------------------------------
1 | package homework2.adapters;
2 |
3 | import java.rmi.RemoteException;
4 | import java.time.ZoneId;
5 |
6 | import homework2.entities.Customer;
7 | import homework2.interfaces.RealPersonService;
8 | import homework2.interfaces.Result;
9 | import tr.gov.nvi.tckimlik.WS.KPSPublicSoapProxy;
10 |
11 | public class MernisServiceAdapter implements RealPersonService{
12 |
13 | public Result CheckIfRealPerson(Customer customer) {
14 | KPSPublicSoapProxy kpsPublicSoapProxy = new KPSPublicSoapProxy();
15 | boolean result = true;
16 |
17 | try {
18 | result = kpsPublicSoapProxy.TCKimlikNoDogrula(
19 | Long.parseLong(customer.getIdentityNumber()),
20 | customer.getFirstName().toUpperCase(),
21 | customer.getLastName().toUpperCase(),
22 | customer.getBirthDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear()
23 | );
24 | } catch (RemoteException e) {
25 | // TODO Auto-generated catch block
26 | e.printStackTrace();
27 | }
28 |
29 | if(result) {
30 | return new homework2.utils.Result(true);
31 | }else {
32 | return new homework2.utils.Result(false, "kimlik doğrulama başarısız.");
33 | }
34 |
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/entities/Customer.java:
--------------------------------------------------------------------------------
1 | package homework2.entities;
2 |
3 | import java.util.Date;
4 |
5 | import homework2.interfaces.Entity;
6 |
7 | public class Customer implements Entity {
8 | private int id;
9 | private String firstName;
10 | private String lastName;
11 | private String identityNumber;
12 | private Date birthDate;
13 |
14 | public Customer() {
15 |
16 | }
17 |
18 | public Customer(int id, String firstName, String lastName, String identityNumber, Date birthDate) {
19 | super();
20 | this.id = id;
21 | this.firstName = firstName;
22 | this.lastName = lastName;
23 | this.identityNumber = identityNumber;
24 | this.birthDate = birthDate;
25 | }
26 |
27 | public int getId() {
28 | return id;
29 | }
30 | public void setId(int id) {
31 | this.id = id;
32 | }
33 | public String getFirstName() {
34 | return firstName;
35 | }
36 | public void setFirstName(String firstName) {
37 | this.firstName = firstName;
38 | }
39 | public String getLastName() {
40 | return lastName;
41 | }
42 | public void setLastName(String lastName) {
43 | this.lastName = lastName;
44 | }
45 | public String getIdentityNumber() {
46 | return identityNumber;
47 | }
48 | public void setIdentityNumber(String identityNumber) {
49 | this.identityNumber = identityNumber;
50 | }
51 | public Date getBirthDate() {
52 | return birthDate;
53 | }
54 | public void setBirthDate(Date birthDate) {
55 | this.birthDate = birthDate;
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/interfaces/CustomerCheckService.java:
--------------------------------------------------------------------------------
1 | package homework2.interfaces;
2 |
3 | import homework2.entities.Customer;
4 |
5 | public interface CustomerCheckService {
6 | Result CheckIfRealPerson(Customer customer);
7 | Result CheckIfYoungerAgeThan(Customer customer, int age);
8 | }
9 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/interfaces/CustomerService.java:
--------------------------------------------------------------------------------
1 | package homework2.interfaces;
2 |
3 | import homework2.entities.Customer;
4 |
5 | public interface CustomerService {
6 | void add(Customer customer);
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/interfaces/Entity.java:
--------------------------------------------------------------------------------
1 | package homework2.interfaces;
2 |
3 | public interface Entity {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/interfaces/RealPersonService.java:
--------------------------------------------------------------------------------
1 | package homework2.interfaces;
2 |
3 | import homework2.entities.Customer;
4 |
5 | public interface RealPersonService {
6 | Result CheckIfRealPerson(Customer customer);
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/interfaces/Result.java:
--------------------------------------------------------------------------------
1 | package homework2.interfaces;
2 |
3 | public interface Result {
4 | boolean isSuccess();
5 | String getMessage();
6 | }
7 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/services/NeroCustomerManager.java:
--------------------------------------------------------------------------------
1 | package homework2.services;
2 |
3 | import homework2.abstracts.CustomerManager;
4 |
5 | public class NeroCustomerManager extends CustomerManager {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/services/StarbucksCustomerCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework2.services;
2 |
3 | import homework2.abstracts.CustomerCheckManager;
4 | import homework2.entities.Customer;
5 | import homework2.interfaces.RealPersonService;
6 | import homework2.interfaces.Result;
7 |
8 | public class StarbucksCustomerCheckManager extends CustomerCheckManager{
9 |
10 | private RealPersonService realPersonService;
11 |
12 | public StarbucksCustomerCheckManager(RealPersonService realPersonService){
13 | this.realPersonService = realPersonService;
14 | }
15 |
16 | @Override
17 | public Result CheckIfRealPerson(Customer customer) {
18 |
19 | return realPersonService.CheckIfRealPerson(customer);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/services/StarbucksCustomerManager.java:
--------------------------------------------------------------------------------
1 | package homework2.services;
2 |
3 | import homework2.abstracts.CustomerManager;
4 | import homework2.entities.Customer;
5 | import homework2.interfaces.CustomerCheckService;
6 | import homework2.interfaces.Result;
7 | import homework2.utils.CheckServiceUtils;
8 |
9 | public class StarbucksCustomerManager extends CustomerManager {
10 |
11 | private CustomerCheckService customerCheckService;
12 |
13 |
14 | public StarbucksCustomerManager(CustomerCheckService customerCheckService) {
15 | this.customerCheckService = customerCheckService;
16 | }
17 |
18 |
19 | @Override
20 | public void add(Customer customer) {
21 |
22 | Result result = CheckServiceUtils.runCheckServices(new Result[] {
23 | customerCheckService.CheckIfRealPerson(customer),
24 | customerCheckService.CheckIfYoungerAgeThan(customer, 15)
25 | });
26 |
27 | if(!result.isSuccess()) {
28 | System.out.println(result.getMessage());
29 | return;
30 | }
31 |
32 | super.add(customer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/utils/CheckServiceUtils.java:
--------------------------------------------------------------------------------
1 | package homework2.utils;
2 |
3 | import homework2.interfaces.Result;
4 |
5 | public class CheckServiceUtils {
6 | public static Result runCheckServices(Result[] customerCheckServices) {
7 | for (Result customerCheckService : customerCheckServices) {
8 | if(!customerCheckService.isSuccess()) {
9 | return customerCheckService;
10 | }
11 | }
12 | return new homework2.utils.Result(true);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/homework2/utils/Result.java:
--------------------------------------------------------------------------------
1 | package homework2.utils;
2 |
3 | public class Result implements homework2.interfaces.Result {
4 | private boolean success;
5 | private String message;
6 |
7 | public Result(boolean success) {
8 | this.success = success;
9 | }
10 |
11 | public Result(Boolean success, String message) {
12 | this(success);
13 | this.message = message;
14 | }
15 |
16 | public boolean isSuccess() {
17 | return success;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/tr/gov/nvi/tckimlik/WS/KPSPublic.java:
--------------------------------------------------------------------------------
1 | /**
2 | * KPSPublic.java
3 | *
4 | * This file was auto-generated from WSDL
5 | * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
6 | */
7 |
8 | package tr.gov.nvi.tckimlik.WS;
9 |
10 | public interface KPSPublic extends javax.xml.rpc.Service {
11 | public java.lang.String getKPSPublicSoapAddress();
12 |
13 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap() throws javax.xml.rpc.ServiceException;
14 |
15 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
16 | }
17 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/tr/gov/nvi/tckimlik/WS/KPSPublicSoap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * KPSPublicSoap.java
3 | *
4 | * This file was auto-generated from WSDL
5 | * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
6 | */
7 |
8 | package tr.gov.nvi.tckimlik.WS;
9 |
10 | public interface KPSPublicSoap extends java.rmi.Remote {
11 | public boolean TCKimlikNoDogrula(long TCKimlikNo, java.lang.String ad, java.lang.String soyad, int dogumYili) throws java.rmi.RemoteException;
12 | }
13 |
--------------------------------------------------------------------------------
/lecture4.2-homework2/src/tr/gov/nvi/tckimlik/WS/KPSPublicSoapProxy.java:
--------------------------------------------------------------------------------
1 | package tr.gov.nvi.tckimlik.WS;
2 |
3 | public class KPSPublicSoapProxy implements tr.gov.nvi.tckimlik.WS.KPSPublicSoap {
4 | private String _endpoint = null;
5 | private tr.gov.nvi.tckimlik.WS.KPSPublicSoap kPSPublicSoap = null;
6 |
7 | public KPSPublicSoapProxy() {
8 | _initKPSPublicSoapProxy();
9 | }
10 |
11 | public KPSPublicSoapProxy(String endpoint) {
12 | _endpoint = endpoint;
13 | _initKPSPublicSoapProxy();
14 | }
15 |
16 | private void _initKPSPublicSoapProxy() {
17 | try {
18 | kPSPublicSoap = (new tr.gov.nvi.tckimlik.WS.KPSPublicLocator()).getKPSPublicSoap();
19 | if (kPSPublicSoap != null) {
20 | if (_endpoint != null)
21 | ((javax.xml.rpc.Stub)kPSPublicSoap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
22 | else
23 | _endpoint = (String)((javax.xml.rpc.Stub)kPSPublicSoap)._getProperty("javax.xml.rpc.service.endpoint.address");
24 | }
25 |
26 | }
27 | catch (javax.xml.rpc.ServiceException serviceException) {}
28 | }
29 |
30 | public String getEndpoint() {
31 | return _endpoint;
32 | }
33 |
34 | public void setEndpoint(String endpoint) {
35 | _endpoint = endpoint;
36 | if (kPSPublicSoap != null)
37 | ((javax.xml.rpc.Stub)kPSPublicSoap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
38 |
39 | }
40 |
41 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap() {
42 | if (kPSPublicSoap == null)
43 | _initKPSPublicSoapProxy();
44 | return kPSPublicSoap;
45 | }
46 |
47 | public boolean TCKimlikNoDogrula(long TCKimlikNo, java.lang.String ad, java.lang.String soyad, int dogumYili) throws java.rmi.RemoteException{
48 | if (kPSPublicSoap == null)
49 | _initKPSPublicSoapProxy();
50 | return kPSPublicSoap.TCKimlikNoDogrula(TCKimlikNo, ad, soyad, dogumYili);
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/lecture4.3-homework3/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture4.3-homework3
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jem.workbench.JavaEMFNature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublic.java=UTF-8
3 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicLocator.java=UTF-8
4 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicSoap.java=UTF-8
5 | encoding//src/tr/gov/nvi/tckimlik/WS/KPSPublicSoapStub.java=UTF-8
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.release=disabled
12 | org.eclipse.jdt.core.compiler.source=1.8
13 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/BaseProductManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import java.util.ArrayList;
4 |
5 | import homework3.Entity.Product;
6 |
7 | public class BaseProductManager implements ProductService {
8 |
9 | @Override
10 | public void add(Product product) {
11 | System.out.println(product.getName() + " : eklenmiştir.");
12 | }
13 |
14 | @Override
15 | public void addBulk(Product[] products) {
16 | for (Product product : products) {
17 | this.add(product);
18 | }
19 | }
20 |
21 | @Override
22 | public void update(Product product) {
23 | System.out.println(product.getName() + " : güncellenmiştir.");
24 | }
25 |
26 | @Override
27 | public void delete(Product product) {
28 | System.out.println(product.getName() + " : silinmiştir.");
29 | }
30 |
31 | @Override
32 | public ArrayList getAll() {
33 | // TODO Auto-generated method stub
34 | return null;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/BaseUserCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public abstract class BaseUserCheckManager implements UserCheckService {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/BaseUserManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import java.util.ArrayList;
4 |
5 | import homework3.Entity.User;
6 |
7 | public abstract class BaseUserManager implements UserService {
8 |
9 | @Override
10 | public void add(User user) {
11 | System.out.println(user.getId() + " : eklenmiştir.");
12 | }
13 |
14 | @Override
15 | public void addBulk(User[] users) {
16 | for (User user : users) {
17 | this.add(user);
18 | }
19 | }
20 |
21 | @Override
22 | public void update(User user) {
23 | System.out.println(user.getId() + " : güncellenmiştir.");
24 |
25 | }
26 |
27 | @Override
28 | public void delete(User user) {
29 | System.out.println(user.getId() + " : silinmiştir.");
30 |
31 | }
32 |
33 | @Override
34 | public ArrayList getAll() {
35 | // TODO Auto-generated method stub
36 | return null;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/CampaignCheckService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public interface CampaignCheckService {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/CampaignService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import homework3.Entity.Campaign;
4 |
5 | public interface CampaignService extends CrudService {
6 | }
7 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/CategoryService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import homework3.Entity.Category;
4 | public interface CategoryService extends CrudService {
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/CrudService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import java.util.ArrayList;
4 |
5 | public interface CrudService {
6 | void add(T entity);
7 | void addBulk(T[] entity);
8 | void update(T entity);
9 | void delete(T entity);
10 | ArrayList getAll();
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/IdentityValidationService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import java.util.Date;
4 |
5 | import homework3.Utils.Result.Result;
6 |
7 | public interface IdentityValidationService {
8 | Result CheckIfRealPerson(Long identityNumber, String firstName, String lastName, int birthYear);
9 | Result CheckIfRealPerson(String identityNumber, String firstName, String lastName, Date birthDate);
10 | Result CheckIfRealPerson(Long identityNumber, String firstName, String lastName, Date birthDate);
11 | }
12 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/OrderCheckService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public interface OrderCheckService {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/OrderConfirmService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public interface OrderConfirmService {
4 | void update(int orderId);
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/OrderRefuseService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public interface OrderRefuseService {
4 | void update(int orderId);
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/OrderService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import java.util.Date;
4 |
5 | public interface OrderService {
6 | void add(Date date, int userId, int productId, int campaignId, int quantity, double unitPrice);
7 | void update(int orderId, Date date, int userId, int productId, int campaignId, int quantity, double unitPrice);
8 | void delete(int orderId);
9 | }
10 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/ProductCheckService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | public interface ProductCheckService {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/ProductService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import homework3.Entity.Product;
4 |
5 | public interface ProductService extends CrudService {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/UserCheckService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import homework3.Entity.User;
4 | import homework3.Utils.Result.Result;
5 |
6 | public interface UserCheckService {
7 | public Result checkIsRealUser(User user);
8 | }
9 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Abstract/UserService.java:
--------------------------------------------------------------------------------
1 | package homework3.Abstract;
2 |
3 | import homework3.Entity.User;
4 |
5 | public interface UserService extends CrudService {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Adapter/MernisServiceAdapter.java:
--------------------------------------------------------------------------------
1 | package homework3.Adapter;
2 |
3 | import java.rmi.RemoteException;
4 | import java.time.ZoneId;
5 | import java.util.Date;
6 |
7 | import homework3.Abstract.IdentityValidationService;
8 | import homework3.Utils.Result.ErrorResult;
9 | import homework3.Utils.Result.Result;
10 | import homework3.Utils.Result.SuccessResult;
11 | import tr.gov.nvi.tckimlik.WS.KPSPublicSoapProxy;
12 |
13 | public class MernisServiceAdapter implements IdentityValidationService{
14 |
15 | @Override
16 | public Result CheckIfRealPerson(Long identityNumber, String firstName, String lastName, int birthYear) {
17 | KPSPublicSoapProxy kpsPublicSoapProxy = new KPSPublicSoapProxy();
18 | boolean result = true;
19 |
20 | try {
21 | result = kpsPublicSoapProxy.TCKimlikNoDogrula(
22 | identityNumber,
23 | firstName.toUpperCase(),
24 | lastName.toUpperCase(),
25 | birthYear
26 | );
27 | } catch (RemoteException e) {
28 | e.printStackTrace();
29 | }
30 | if(result) {
31 | return new SuccessResult();
32 | }else {
33 | return new ErrorResult(firstName.toUpperCase() + " " + lastName.toUpperCase() + " : Kimlik doğrulama başarısız.");
34 | }
35 |
36 | }
37 |
38 | /*
39 | * For a `String` identityNumber
40 | * */
41 | @Override
42 | public Result CheckIfRealPerson(String identityNumber, String firstName, String lastName, Date birthDate) {
43 | return this.CheckIfRealPerson(
44 | Long.parseLong(identityNumber),
45 | firstName,
46 | lastName,
47 | birthDate
48 | );
49 | }
50 | /*
51 | * For a `Date` birthDate
52 | * */
53 | @Override
54 | public Result CheckIfRealPerson(Long identityNumber, String firstName, String lastName, Date birthDate) {
55 | return this.CheckIfRealPerson(
56 | identityNumber,
57 | firstName,
58 | lastName,
59 | birthDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear()
60 | );
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/CampaignManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import java.util.ArrayList;
4 |
5 | import homework3.Abstract.CampaignService;
6 | import homework3.Entity.Campaign;
7 |
8 | public class CampaignManager implements CampaignService {
9 |
10 | @Override
11 | public void add(Campaign campaign) {
12 | System.out.println("Product : " + campaign.getProduct().getName() + " , Campaign Code : " + campaign.getCampaignCode() + " created.");
13 | }
14 |
15 | @Override
16 | public void addBulk(Campaign[] entity) {
17 | // TODO Auto-generated method stub
18 |
19 | }
20 |
21 | @Override
22 | public void update(Campaign campaign) {
23 | System.out.println("Product : " + campaign.getProduct().getName() + " , Campaign Code : " + campaign.getCampaignCode() + " updated.");
24 | }
25 |
26 | @Override
27 | public void delete(Campaign campaign) {
28 | System.out.println("Product : " + campaign.getProduct().getName() + " , Campaign Code : " + campaign.getCampaignCode() + " deleted.");
29 | }
30 |
31 | @Override
32 | public ArrayList getAll() {
33 | // TODO Auto-generated method stub
34 | return null;
35 | }
36 |
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/CategoryManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import java.util.ArrayList;
4 |
5 | import homework3.Abstract.CategoryService;
6 | import homework3.Entity.Category;
7 |
8 | public class CategoryManager implements CategoryService {
9 |
10 | @Override
11 | public void add(Category category) {
12 | System.out.println(category.getName() + " : eklenmiştir.");
13 |
14 | }
15 |
16 | @Override
17 | public void addBulk(Category[] categories) {
18 | for (Category category : categories) {
19 | this.add(category);
20 | }
21 | }
22 |
23 | @Override
24 | public void update(Category category) {
25 | System.out.println(category.getName() + " : güncellenmiştir.");
26 |
27 | }
28 |
29 | @Override
30 | public void delete(Category category) {
31 | System.out.println(category.getName() + " : silinmiştir.");
32 |
33 | }
34 |
35 | @Override
36 | public ArrayList getAll() {
37 | // TODO Auto-generated method stub
38 | return null;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/GameManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import homework3.Abstract.BaseProductManager;
4 |
5 | public class GameManager extends BaseProductManager {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/GameProducerManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import homework3.Abstract.BaseUserManager;
4 |
5 | public class GameProducerManager extends BaseUserManager {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/OrderManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import java.util.Date;
4 |
5 | import homework3.Abstract.CampaignService;
6 | import homework3.Abstract.OrderService;
7 | import homework3.Abstract.ProductService;
8 | import homework3.Abstract.UserService;
9 | import homework3.Entity.Order;
10 |
11 | public class OrderManager implements OrderService {
12 |
13 | private UserService userService;
14 | private ProductService productService;
15 | private CampaignService campaignService;
16 |
17 | public OrderManager(UserService userService, ProductService productService, CampaignService campaignService) {
18 | this.userService = userService;
19 | this.productService = productService;
20 | this.campaignService = campaignService;
21 | }
22 |
23 | @Override
24 | public void add(Date date, int userId, int productId, int campaignId, int quantity, double unitPrice) {
25 |
26 | Order order = new Order(1, date, userId, productId, campaignId, quantity, unitPrice, 0, 0);
27 |
28 | System.out.println("|orderId|date|userId|productId|campaignId|quantity|unitPrice|discountPercent|discountedPrice|");
29 | System.out.println("|---|---|---|---|---|---|---|---|---|");
30 | System.out.println(
31 | "|" + order.getId()
32 | + "|" + order.getDate()
33 | + "|" + order.getUserId()
34 | + "|" + order.getProductId()
35 | + "|" + order.getCampaignId()
36 | + "|" + order.getQuantity()
37 | + "|" + order.getUnitPrice()
38 | + "|" + order.getDiscountPercent()
39 | + "|" + order.getDiscountedPrice()
40 | );
41 |
42 |
43 | }
44 |
45 |
46 | @Override
47 | public void update(int orderId, Date date, int userId, int productId, int campaignId, int quantity, double unitPrice) {
48 | System.out.println("Order : " + orderId + " updated. ");
49 | }
50 |
51 | @Override
52 | public void delete(int orderId) {
53 | System.out.println("Order : " + orderId + " deleted. ");
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/PlayerCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import homework3.Abstract.BaseUserCheckManager;
4 | import homework3.Abstract.IdentityValidationService;
5 | import homework3.Entity.Player;
6 | import homework3.Entity.User;
7 | import homework3.Utils.Result.Result;
8 |
9 | public class PlayerCheckManager extends BaseUserCheckManager {
10 | private IdentityValidationService identityValidationService;
11 |
12 | public PlayerCheckManager(IdentityValidationService identityValidationService){
13 | this.identityValidationService = identityValidationService;
14 | }
15 |
16 | @Override
17 | public Result checkIsRealUser(User user) {
18 | Player player = (Player)user;
19 | return this.identityValidationService.CheckIfRealPerson(
20 | player.getIdentityNumber(),
21 | player.getFirstName(),
22 | player.getLastName(),
23 | player.getBirthDate()
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/PlayerManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.function.Predicate;
6 | import java.util.stream.Collectors;
7 |
8 | import homework3.Abstract.BaseUserManager;
9 | import homework3.Abstract.UserCheckService;
10 | import homework3.Entity.User;
11 | import homework3.Utils.ServiceUtils;
12 | import homework3.Utils.Result.Result;
13 |
14 | public class PlayerManager extends BaseUserManager {
15 | private UserCheckService userCheckService;
16 |
17 | public PlayerManager(UserCheckService userCheckService) {
18 | this.userCheckService = userCheckService;
19 | }
20 |
21 | @Override
22 | public void add(User user) {
23 | Result result = ServiceUtils.runChecks(
24 | userCheckService.checkIsRealUser(user)
25 | );
26 |
27 | if(!result.isSuccess()) {
28 | System.out.println(result.getMessage());
29 | return;
30 | }
31 |
32 | super.add(user);
33 | }
34 |
35 | @Override
36 | public void addBulk(User[] users) {
37 | for (User user : users) {
38 | this.add(user);
39 | }
40 | }
41 |
42 | @Override
43 | public void update(User user) {
44 | // TODO Auto-generated method stub
45 |
46 | }
47 |
48 | @Override
49 | public void delete(User user) {
50 | // TODO Auto-generated method stub
51 |
52 | }
53 |
54 | public List get(Predicate predicate){
55 | List list = new ArrayList();
56 | User user = new User(1, "111");
57 | list.add(user);
58 | return list.stream().filter(predicate).collect(Collectors.toList());
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Concrete/SalesmanManager.java:
--------------------------------------------------------------------------------
1 | package homework3.Concrete;
2 |
3 | import homework3.Abstract.BaseUserManager;
4 |
5 | public class SalesmanManager extends BaseUserManager {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Campaign.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | import java.util.Date;
4 |
5 | public class Campaign {
6 | private int id;
7 | private String campaignCode;
8 | private Product product;
9 | private String name;
10 | private String description;
11 | private double discountPercent;
12 | private Date startDate;
13 | private Date endDate;
14 |
15 |
16 | public Campaign(int id, String campaignCode, Product product, String name, String description, double discountPercent, Date startDate,
17 | Date endDate) {
18 | this.id = id;
19 | this.campaignCode = campaignCode;
20 | this.product = product;
21 | this.name = name;
22 | this.description = description;
23 | this.discountPercent = discountPercent;
24 | this.startDate = startDate;
25 | this.endDate = endDate;
26 | }
27 |
28 | public int getId() {
29 | return id;
30 | }
31 |
32 | public void setId(int id) {
33 | this.id = id;
34 | }
35 |
36 | public String getCampaignCode() {
37 | return campaignCode;
38 | }
39 |
40 | public void setCampaignCode(String campaignCode) {
41 | this.campaignCode = campaignCode;
42 | }
43 |
44 | public Product getProduct() {
45 | return product;
46 | }
47 |
48 | public void setProduct(Product product) {
49 | this.product = product;
50 | }
51 |
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | public void setName(String name) {
57 | this.name = name;
58 | }
59 |
60 | public String getDescription() {
61 | return description;
62 | }
63 |
64 | public void setDescription(String description) {
65 | this.description = description;
66 | }
67 |
68 | public double getDiscountPercent() {
69 | return discountPercent;
70 | }
71 |
72 | public void setDiscountPercent(double discountPercent) {
73 | this.discountPercent = discountPercent;
74 | }
75 |
76 | public Date getStartDate() {
77 | return startDate;
78 | }
79 |
80 | public void setStartDate(Date startDate) {
81 | this.startDate = startDate;
82 | }
83 |
84 | public Date getEndDate() {
85 | return endDate;
86 | }
87 |
88 | public void setEndDate(Date endDate) {
89 | this.endDate = endDate;
90 | }
91 |
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Category.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class Category {
4 | private int id;
5 | private String name;
6 | private int parentId;
7 |
8 | public Category(int id, String name, int parentId) {
9 | this.id = id;
10 | this.name = name;
11 | this.parentId = parentId;
12 | }
13 |
14 | public int getId() {
15 | return id;
16 | }
17 |
18 | public void setId(int id) {
19 | this.id = id;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public void setName(String name) {
27 | this.name = name;
28 | }
29 |
30 | public int getParentId() {
31 | return parentId;
32 | }
33 |
34 | public void setParentId(int parentId) {
35 | this.parentId = parentId;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Game.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class Game extends Product {
4 | private int gameProducerId;
5 |
6 | public Game(int id, String name, String description, double sellingPrice, int categoryId, int gameProducerId) {
7 | super(id, name, description, sellingPrice, categoryId);
8 | this.gameProducerId = gameProducerId;
9 | }
10 |
11 | public int getGameProducerId() {
12 | return gameProducerId;
13 | }
14 |
15 | public void setGameProducerId(int gameProducerId) {
16 | this.gameProducerId = gameProducerId;
17 | }
18 |
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/GameProducer.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class GameProducer extends User {
4 | private String name;
5 | private String description;
6 |
7 | public GameProducer(int id, String userCode, String name, String description) {
8 | super(id, userCode);
9 | this.name = name;
10 | this.description = description;
11 | }
12 |
13 | public String getName() {
14 | return name;
15 | }
16 |
17 | public void setName(String name) {
18 | this.name = name;
19 | }
20 |
21 | public String getDescription() {
22 | return description;
23 | }
24 |
25 | public void setDescription(String description) {
26 | this.description = description;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Player.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | import java.util.Date;
4 |
5 | public class Player extends User {
6 |
7 | private String firstName;
8 | private String lastName;
9 | private String identityNumber;
10 | private Date birthDate;
11 |
12 | public Player(int id, String userCode, String firstName, String lastName, String identityNumber, Date birthDate) {
13 | super(id, userCode);
14 | this.firstName = firstName;
15 | this.lastName = lastName;
16 | this.identityNumber = identityNumber;
17 | this.birthDate = birthDate;
18 | }
19 |
20 | public String getFirstName() {
21 | return firstName;
22 | }
23 |
24 | public void setFirstName(String firstName) {
25 | this.firstName = firstName;
26 | }
27 |
28 | public String getLastName() {
29 | return lastName;
30 | }
31 |
32 | public void setLastName(String lastName) {
33 | this.lastName = lastName;
34 | }
35 |
36 | public String getIdentityNumber() {
37 | return identityNumber;
38 | }
39 |
40 | public void setIdentityNumber(String identityNumber) {
41 | this.identityNumber = identityNumber;
42 | }
43 |
44 | public Date getBirthDate() {
45 | return birthDate;
46 | }
47 |
48 | public void setBirthDate(Date birthDate) {
49 | this.birthDate = birthDate;
50 | }
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Product.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class Product {
4 | private int id;
5 | private String name;
6 | private String description;
7 | private double sellingPrice;
8 | private int categoryId;
9 |
10 | public Product(int id, String name, String description, double sellingPrice, int categoryId) {
11 | this.id = id;
12 | this.name = name;
13 | this.description = description;
14 | this.sellingPrice = sellingPrice;
15 | this.categoryId = categoryId;
16 | }
17 |
18 | public int getId() {
19 | return id;
20 | }
21 |
22 | public void setId(int id) {
23 | this.id = id;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getDescription() {
35 | return description;
36 | }
37 |
38 | public void setDescription(String description) {
39 | this.description = description;
40 | }
41 |
42 | public double getSellingPrice() {
43 | return sellingPrice;
44 | }
45 |
46 | public void setSellingPrice(double sellingPrice) {
47 | this.sellingPrice = sellingPrice;
48 | }
49 |
50 | public int getCategoryId() {
51 | return categoryId;
52 | }
53 |
54 | public void setCategoryId(int categoryId) {
55 | this.categoryId = categoryId;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/Salesman.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class Salesman extends User {
4 | private String firstName;
5 | private String lastName;
6 |
7 | public Salesman(int id, String userCode, String firstName, String lastName) {
8 | super(id, userCode);
9 | this.firstName = firstName;
10 | this.lastName = lastName;
11 | }
12 |
13 | public String getFirstName() {
14 | return firstName;
15 | }
16 | public void setFirstName(String firstName) {
17 | this.firstName = firstName;
18 | }
19 | public String getLastName() {
20 | return lastName;
21 | }
22 | public void setLastName(String lastName) {
23 | this.lastName = lastName;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Entity/User.java:
--------------------------------------------------------------------------------
1 | package homework3.Entity;
2 |
3 | public class User {
4 | private int id;
5 | private String userCode;
6 |
7 | public User(int id, String userCode) {
8 | this.id = id;
9 | this.userCode = userCode;
10 | }
11 |
12 | public int getId() {
13 | return id;
14 | }
15 | public void setId(int id) {
16 | this.id = id;
17 | }
18 | public String getUserCode() {
19 | return userCode;
20 | }
21 | public void setUserCode(String userCode) {
22 | this.userCode = userCode;
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Utils/Result/ErrorResult.java:
--------------------------------------------------------------------------------
1 | package homework3.Utils.Result;
2 |
3 | public class ErrorResult implements Result {
4 | private final boolean success;
5 | private String message;
6 |
7 | public ErrorResult() {
8 | this.success = false;
9 | }
10 |
11 | public ErrorResult(String message) {
12 | this();
13 | this.message = message;
14 | }
15 |
16 | public boolean isSuccess() {
17 | return success;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Utils/Result/Result.java:
--------------------------------------------------------------------------------
1 | package homework3.Utils.Result;
2 |
3 | public interface Result {
4 | boolean isSuccess();
5 | String getMessage();
6 | }
7 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Utils/Result/SuccessResult.java:
--------------------------------------------------------------------------------
1 | package homework3.Utils.Result;
2 |
3 | public class SuccessResult implements Result {
4 | private boolean success;
5 | private String message;
6 |
7 | public SuccessResult() {
8 | this.success = true;
9 | }
10 |
11 | public SuccessResult(Boolean success, String message) {
12 | this();
13 | this.message = message;
14 | }
15 |
16 | public boolean isSuccess() {
17 | return success;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/homework3/Utils/ServiceUtils.java:
--------------------------------------------------------------------------------
1 | package homework3.Utils;
2 |
3 |
4 | import homework3.Utils.Result.Result;
5 | import homework3.Utils.Result.SuccessResult;
6 |
7 | public class ServiceUtils {
8 | public static Result runChecks(Result... results) {
9 | for (Result result : results) {
10 | if(!result.isSuccess()) {
11 | return result;
12 | }
13 | }
14 | return new SuccessResult();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/tr/gov/nvi/tckimlik/WS/KPSPublic.java:
--------------------------------------------------------------------------------
1 | /**
2 | * KPSPublic.java
3 | *
4 | * This file was auto-generated from WSDL
5 | * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
6 | */
7 |
8 | package tr.gov.nvi.tckimlik.WS;
9 |
10 | public interface KPSPublic extends javax.xml.rpc.Service {
11 | public java.lang.String getKPSPublicSoapAddress();
12 |
13 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap() throws javax.xml.rpc.ServiceException;
14 |
15 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
16 | }
17 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/tr/gov/nvi/tckimlik/WS/KPSPublicSoap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * KPSPublicSoap.java
3 | *
4 | * This file was auto-generated from WSDL
5 | * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
6 | */
7 |
8 | package tr.gov.nvi.tckimlik.WS;
9 |
10 | public interface KPSPublicSoap extends java.rmi.Remote {
11 | public boolean TCKimlikNoDogrula(long TCKimlikNo, java.lang.String ad, java.lang.String soyad, int dogumYili) throws java.rmi.RemoteException;
12 | }
13 |
--------------------------------------------------------------------------------
/lecture4.3-homework3/src/tr/gov/nvi/tckimlik/WS/KPSPublicSoapProxy.java:
--------------------------------------------------------------------------------
1 | package tr.gov.nvi.tckimlik.WS;
2 |
3 | public class KPSPublicSoapProxy implements tr.gov.nvi.tckimlik.WS.KPSPublicSoap {
4 | private String _endpoint = null;
5 | private tr.gov.nvi.tckimlik.WS.KPSPublicSoap kPSPublicSoap = null;
6 |
7 | public KPSPublicSoapProxy() {
8 | _initKPSPublicSoapProxy();
9 | }
10 |
11 | public KPSPublicSoapProxy(String endpoint) {
12 | _endpoint = endpoint;
13 | _initKPSPublicSoapProxy();
14 | }
15 |
16 | private void _initKPSPublicSoapProxy() {
17 | try {
18 | kPSPublicSoap = (new tr.gov.nvi.tckimlik.WS.KPSPublicLocator()).getKPSPublicSoap();
19 | if (kPSPublicSoap != null) {
20 | if (_endpoint != null)
21 | ((javax.xml.rpc.Stub)kPSPublicSoap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
22 | else
23 | _endpoint = (String)((javax.xml.rpc.Stub)kPSPublicSoap)._getProperty("javax.xml.rpc.service.endpoint.address");
24 | }
25 |
26 | }
27 | catch (javax.xml.rpc.ServiceException serviceException) {}
28 | }
29 |
30 | public String getEndpoint() {
31 | return _endpoint;
32 | }
33 |
34 | public void setEndpoint(String endpoint) {
35 | _endpoint = endpoint;
36 | if (kPSPublicSoap != null)
37 | ((javax.xml.rpc.Stub)kPSPublicSoap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
38 |
39 | }
40 |
41 | public tr.gov.nvi.tckimlik.WS.KPSPublicSoap getKPSPublicSoap() {
42 | if (kPSPublicSoap == null)
43 | _initKPSPublicSoapProxy();
44 | return kPSPublicSoap;
45 | }
46 |
47 | public boolean TCKimlikNoDogrula(long TCKimlikNo, java.lang.String ad, java.lang.String soyad, int dogumYili) throws java.rmi.RemoteException{
48 | if (kPSPublicSoap == null)
49 | _initKPSPublicSoapProxy();
50 | return kPSPublicSoap.TCKimlikNoDogrula(TCKimlikNo, ad, soyad, dogumYili);
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture5.1-nLayeredDemo
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/Main.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo;
2 |
3 | import nLayeredDemo.business.abstracts.ProductService;
4 | import nLayeredDemo.business.concretes.ProductManager;
5 | import nLayeredDemo.core.JLoggerManagerAdapter;
6 | import nLayeredDemo.dataAccess.concretes.AbcProductDao;
7 | import nLayeredDemo.entities.concretes.Product;
8 |
9 | public class Main {
10 |
11 | public static void main(String[] args) {
12 |
13 | //FIXME: Spring IoC
14 | ProductService productService = new ProductManager(new AbcProductDao(), new JLoggerManagerAdapter());
15 |
16 | Product product = new Product(1,2,"Elma",12,50);
17 | productService.add(product);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/business/abstracts/ProductService.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.business.abstracts;
2 |
3 | import java.util.List;
4 |
5 | import nLayeredDemo.entities.concretes.Product;
6 |
7 | public interface ProductService {
8 | void add(Product product);
9 | List getAll();
10 | }
11 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/business/concretes/ProductManager.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.business.concretes;
2 |
3 | import java.util.List;
4 |
5 | import nLayeredDemo.business.abstracts.ProductService;
6 | import nLayeredDemo.core.LoggerService;
7 | import nLayeredDemo.dataAccess.abstracts.ProductDao;
8 | import nLayeredDemo.entities.concretes.Product;
9 |
10 | public class ProductManager implements ProductService {
11 |
12 | private ProductDao productDao;
13 | private LoggerService loggerService;
14 |
15 | public ProductManager(ProductDao productDao, LoggerService loggerService) {
16 | super();
17 | this.productDao = productDao;
18 | this.loggerService = loggerService;
19 | }
20 |
21 | @Override
22 | public void add(Product product) {
23 | if(product.getCategoryId() == 1) {
24 | System.out.println("Bu kategoride ürün kabul edilmyor");
25 | return;
26 | }
27 |
28 | this.productDao.add(product);
29 | this.loggerService.logToSystem("Ürün eklendi " + product.getName());
30 | }
31 |
32 | @Override
33 | public List getAll() {
34 | // TODO Auto-generated method stub
35 | return null;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/core/JLoggerManagerAdapter.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.core;
2 |
3 | import nLayeredDemo.jLogger.JLoggerManager;
4 |
5 | public class JLoggerManagerAdapter implements LoggerService{
6 |
7 | @Override
8 | public void logToSystem(String message) {
9 | JLoggerManager jLoggerManager = new JLoggerManager();
10 | jLoggerManager.log(message);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/core/LoggerService.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.core;
2 |
3 | public interface LoggerService {
4 | void logToSystem(String message);
5 | }
6 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/dataAccess/abstracts/ProductDao.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.dataAccess.abstracts;
2 |
3 | import java.util.List;
4 |
5 | import nLayeredDemo.entities.concretes.Product;
6 |
7 | public interface ProductDao {
8 | void add(Product product);
9 | void update(Product product);
10 | void delete(Product product);
11 | Product get(int id);
12 | List getAll();
13 | }
14 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/dataAccess/concretes/AbcProductDao.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.dataAccess.concretes;
2 |
3 | import java.util.List;
4 |
5 | import nLayeredDemo.dataAccess.abstracts.ProductDao;
6 | import nLayeredDemo.entities.concretes.Product;
7 |
8 | public class AbcProductDao implements ProductDao {
9 |
10 | @Override
11 | public void add(Product product) {
12 | System.out.println("Abc ile eklendi " + product.getName());
13 |
14 | }
15 |
16 | @Override
17 | public void update(Product product) {
18 | // TODO Auto-generated method stub
19 |
20 | }
21 |
22 | @Override
23 | public void delete(Product product) {
24 | // TODO Auto-generated method stub
25 |
26 | }
27 |
28 | @Override
29 | public Product get(int id) {
30 | // TODO Auto-generated method stub
31 | return null;
32 | }
33 |
34 | @Override
35 | public List getAll() {
36 | // TODO Auto-generated method stub
37 | return null;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/dataAccess/concretes/HibernateProductDao.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.dataAccess.concretes;
2 |
3 | import java.util.List;
4 |
5 | import nLayeredDemo.dataAccess.abstracts.ProductDao;
6 | import nLayeredDemo.entities.concretes.Product;
7 |
8 | public class HibernateProductDao implements ProductDao {
9 |
10 | @Override
11 | public void add(Product product) {
12 | System.out.println("Hibernate ile eklendi " + product.getName());
13 |
14 | }
15 |
16 | @Override
17 | public void update(Product product) {
18 | // TODO Auto-generated method stub
19 |
20 | }
21 |
22 | @Override
23 | public void delete(Product product) {
24 | // TODO Auto-generated method stub
25 |
26 | }
27 |
28 | @Override
29 | public Product get(int id) {
30 | // TODO Auto-generated method stub
31 | return null;
32 | }
33 |
34 | @Override
35 | public List getAll() {
36 | // TODO Auto-generated method stub
37 | return null;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/entities/abstracts/Entity.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.entities.abstracts;
2 |
3 | public interface Entity {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/entities/concretes/Product.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.entities.concretes;
2 |
3 | import nLayeredDemo.entities.abstracts.Entity;
4 |
5 | public class Product implements Entity {
6 | private int id;
7 | private int categoryId;
8 | private String name;
9 | private double unitPrice;
10 | private double unitsInStock;
11 |
12 | public Product() {
13 | }
14 |
15 | public Product(int id, int categoryId, String name, double unitPrice, double unitsInStock) {
16 | super();
17 | this.id = id;
18 | this.categoryId = categoryId;
19 | this.name = name;
20 | this.unitPrice = unitPrice;
21 | this.unitsInStock = unitsInStock;
22 | }
23 |
24 | public int getId() {
25 | return id;
26 | }
27 |
28 | public void setId(int id) {
29 | this.id = id;
30 | }
31 |
32 | public int getCategoryId() {
33 | return categoryId;
34 | }
35 |
36 | public void setCategoryId(int categoryId) {
37 | this.categoryId = categoryId;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public double getUnitPrice() {
49 | return unitPrice;
50 | }
51 |
52 | public void setUnitPrice(double unitPrice) {
53 | this.unitPrice = unitPrice;
54 | }
55 |
56 | public double getUnitsInStock() {
57 | return unitsInStock;
58 | }
59 |
60 | public void setUnitsInStock(double unitsInStock) {
61 | this.unitsInStock = unitsInStock;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lecture5.1-nLayeredDemo/src/nLayeredDemo/jLogger/JLoggerManager.java:
--------------------------------------------------------------------------------
1 | package nLayeredDemo.jLogger;
2 |
3 | public class JLoggerManager {
4 | public void log(String message) {
5 | System.out.println("J Logger ile loglandı");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture5.2-homework/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/lecture5.2-homework/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lecture5.2-homework
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture5.2-homework/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/AuthCheckService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 |
4 | public interface AuthCheckService {
5 | void checkForRegister(String email, String password) throws Exception ;
6 | }
7 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/AuthService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface AuthService {
6 | public void login(String email, String password);
7 | public void register(User user);
8 | }
9 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/BaseSignUpManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.core.utils.security.signUp.SignUpService;
4 | import homework.entity.concretes.User;
5 |
6 | public abstract class BaseSignUpManager implements SignUpService{
7 |
8 | private UserService userService;
9 |
10 | public BaseSignUpManager(UserService userService) {
11 | this.userService = userService;
12 | }
13 |
14 | @Override
15 | public void register(User user) {
16 | this.userService.add(user);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/UserActivationService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface UserActivationService {
6 | public void add(User user);
7 | public void check(String activationCode);
8 | }
9 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/UserCheckService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface UserCheckService {
6 | void checkForAdd(User user) throws Exception ;
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/UserService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.core.utils.crud.BaseCrud;
4 | import homework.entity.concretes.User;
5 |
6 | public interface UserService extends BaseCrud {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/abstracts/UserValidationService.java:
--------------------------------------------------------------------------------
1 | package homework.business.abstracts;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface UserValidationService {
6 | public void validateForAdd(User user) throws Exception;
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/adapters/GoogleSignUpManagerAdapter.java:
--------------------------------------------------------------------------------
1 | package homework.business.adapters;
2 |
3 | import homework.business.abstracts.BaseSignUpManager;
4 | import homework.business.abstracts.UserService;
5 | import homework.core.utils.consts.ValidationMessage;
6 | import homework.entity.concretes.User;
7 | import homework.googleAuth.GoogleSignUpManager;
8 |
9 | public class GoogleSignUpManagerAdapter extends BaseSignUpManager {
10 |
11 |
12 |
13 | public GoogleSignUpManagerAdapter(UserService userService) {
14 | super(userService);
15 | }
16 |
17 | @Override
18 | public void register(User user) {
19 | GoogleSignUpManager googleSignUpManager = new GoogleSignUpManager();
20 | boolean result = googleSignUpManager.login(user.getEmail());
21 | if(result) {
22 | super.register(user);
23 | System.out.println(ValidationMessage.googleSignUpSuccessful);
24 | }else {
25 | System.out.println(ValidationMessage.googleSignUpFailed);
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/concretes/AuthCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.concretes;
2 |
3 | import homework.business.abstracts.AuthCheckService;
4 | import homework.business.abstracts.UserService;
5 | import homework.core.utils.ServiceUtils;
6 | import homework.core.utils.consts.ValidationMessage;
7 | import homework.core.utils.result.ErrorResult;
8 | import homework.core.utils.result.Result;
9 | import homework.core.utils.result.SuccessResult;
10 | import homework.entity.concretes.User;
11 |
12 | public class AuthCheckManager implements AuthCheckService {
13 |
14 | private UserService userService;
15 |
16 | public AuthCheckManager(UserService userService) {
17 | this.userService = userService;
18 | }
19 |
20 | @Override
21 | public void checkForRegister(String email, String password) throws Exception{
22 | Result[] results = ServiceUtils.runChecks(
23 | checkUserIsExists(email,password),
24 | checkUserIsActive(email)
25 | );
26 | this.check(results);
27 | }
28 |
29 |
30 | private void check(Result[] results) throws Exception{
31 |
32 | for (Result result : results) {
33 | if (!result.isSuccess()) {
34 | throw new Exception(result.getMessage());
35 | }
36 | }
37 | }
38 |
39 | private Result checkUserIsExists(String email, String password) {
40 | User user = this.userService.get(u -> u.getEmail() == email && u.getPassword() == password);
41 | if(user != null & !user.isActive()) {
42 | return new ErrorResult(ValidationMessage.needActivateUser);
43 | }
44 |
45 | return new SuccessResult();
46 | }
47 |
48 | private Result checkUserIsActive(String email) {
49 | if(this.userService.get(u -> u.getEmail() == email) != null) {
50 | return new ErrorResult(ValidationMessage.emailAlreadyExists);
51 | }
52 |
53 | return new SuccessResult();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/concretes/AuthManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.concretes;
2 |
3 | import homework.business.abstracts.AuthCheckService;
4 | import homework.business.abstracts.AuthService;
5 | import homework.business.abstracts.UserActivationService;
6 | import homework.core.utils.consts.ValidationMessage;
7 | import homework.core.utils.security.signUp.SignUpService;
8 | import homework.entity.concretes.User;
9 |
10 | public class AuthManager implements AuthService {
11 |
12 | private AuthCheckService authCheckService;
13 | private SignUpService signUpService;
14 | private UserActivationService userActivationService;
15 |
16 | public AuthManager(AuthCheckService authCheckService, SignUpService signUpService, UserActivationService userActivationService) {
17 | this.authCheckService = authCheckService;
18 | this.signUpService = signUpService;
19 | this.userActivationService = userActivationService;
20 |
21 | }
22 |
23 | @Override
24 | public void login(String email, String password) {
25 | boolean thrown = false;
26 | try {
27 | this.authCheckService.checkForRegister(email,password);
28 | } catch (Exception e) {
29 | thrown = true;
30 | e.printStackTrace();
31 | } finally {
32 |
33 | if(!thrown) {
34 | System.out.println(ValidationMessage.userEmailOrPasswordNotFound);
35 | }
36 | }
37 |
38 |
39 |
40 | }
41 |
42 | @Override
43 | public void register(User user) {
44 | this.signUpService.register(user);
45 | this.userActivationService.add(user);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/concretes/SignUpManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.concretes;
2 |
3 | import homework.business.abstracts.BaseSignUpManager;
4 | import homework.business.abstracts.UserService;
5 |
6 | public class SignUpManager extends BaseSignUpManager {
7 |
8 |
9 | public SignUpManager(UserService userService) {
10 | super(userService);
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/concretes/UserCheckManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.concretes;
2 |
3 | import homework.business.abstracts.UserCheckService;
4 | import homework.core.utils.ServiceUtils;
5 | import homework.core.utils.consts.ValidationMessage;
6 | import homework.core.utils.result.ErrorResult;
7 | import homework.core.utils.result.Result;
8 | import homework.core.utils.result.SuccessResult;
9 | import homework.dataAccess.abstracts.UserDao;
10 | import homework.entity.concretes.User;
11 |
12 | public class UserCheckManager implements UserCheckService {
13 |
14 | private UserDao userDao;
15 |
16 | public UserCheckManager(UserDao userDao) {
17 | this.userDao = userDao;
18 | }
19 |
20 | @Override
21 | public void checkForAdd(User user) throws Exception{
22 | Result[] results = ServiceUtils.runChecks(checkDuplicateEmail(user.getEmail()));
23 | this.check(results);
24 | }
25 |
26 | private void check(Result[] results) throws Exception {
27 | for (Result result : results) {
28 | if (!result.isSuccess()) {
29 | throw new Exception(result.getMessage());
30 | }
31 | }
32 | }
33 |
34 | private Result checkDuplicateEmail(String email) {
35 | if(this.userDao.get(u -> u.getEmail() == email) != null) {
36 | return new ErrorResult(ValidationMessage.emailAlreadyExists);
37 | }
38 |
39 | return new SuccessResult();
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/concretes/UserManager.java:
--------------------------------------------------------------------------------
1 | package homework.business.concretes;
2 |
3 | import java.util.List;
4 | import java.util.function.Predicate;
5 |
6 | import homework.business.abstracts.UserActivationService;
7 | import homework.business.abstracts.UserCheckService;
8 | import homework.business.abstracts.UserService;
9 | import homework.business.abstracts.UserValidationService;
10 | import homework.dataAccess.abstracts.UserDao;
11 | import homework.entity.concretes.User;
12 |
13 | public class UserManager implements UserService {
14 |
15 | private UserDao userDao;
16 | private UserValidationService userValidationService;
17 | private UserCheckService userCheckService;
18 |
19 | public UserManager(UserDao userDao, UserValidationService userValidationService, UserCheckService userCheckService) {
20 | this.userDao = userDao;
21 | this.userValidationService = userValidationService;
22 | this.userCheckService = userCheckService;
23 | }
24 |
25 | @Override
26 | public void add(User user) {
27 | boolean thrown = false;
28 | try {
29 | this.userValidationService.validateForAdd(user);
30 | this.userCheckService.checkForAdd(user);
31 |
32 |
33 | } catch (Exception e) {
34 | thrown = true;
35 | e.printStackTrace();
36 | } finally {
37 |
38 | if(!thrown) {
39 | this.userDao.add(user);
40 | System.out.println("User created : " + user.toString());
41 | }
42 | }
43 | }
44 |
45 | @Override
46 | public void update(User user) {
47 | try {
48 | this.userValidationService.validateForAdd(user);
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | return;
52 | }
53 |
54 | this.userDao.update(user);
55 | }
56 |
57 | @Override
58 | public void delete(User user) {
59 | this.userDao.delete(user);
60 | }
61 |
62 | @Override
63 | public User get(Predicate predicate) {
64 | return this.userDao.get(predicate);
65 | }
66 |
67 | @Override
68 | public List getAll() {
69 | return this.userDao.getAll();
70 | }
71 |
72 | @Override
73 | public List getAll(Predicate predicate) {
74 | return this.userDao.getAll(predicate);
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/business/consts/Environment.java:
--------------------------------------------------------------------------------
1 | package homework.business.consts;
2 |
3 | public class Environment {
4 | public static String url = "http://e-commerce.com";
5 | public static String activationPath = "/userActivation/actiovationCode=";
6 | }
7 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/dataAccess/abstracts/Entity.java:
--------------------------------------------------------------------------------
1 | package homework.core.dataAccess.abstracts;
2 |
3 | public interface Entity {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/ServiceUtils.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import homework.core.utils.result.Result;
7 |
8 | public class ServiceUtils {
9 | public static Result[] runValidates(Result... results) {
10 | List resultList = new ArrayList();
11 | for (Result result : results) {
12 | if(!result.isSuccess()) {
13 | resultList.add(result);
14 | }
15 | }
16 | return resultList.toArray(new Result[resultList.size()]);
17 | }
18 |
19 | public static Result[] runChecks(Result... results) {
20 | return runValidates(results);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/consts/ValidationMessage.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.consts;
2 |
3 | public class ValidationMessage {
4 | public static String firstNameCanNotBeNullOrEmpty = "First name can not be null or empty.";
5 | public static String lastNameCanNotBeNullOrEmpty = "Last name can not be null or empty.";
6 | public static String emailCanNotBeNullOrEmpty = "E-mail can not be null or empty.";
7 | public static String passwordCanNotBeNullOrEmpty = "Password name can not be null or empty.";
8 | public static String passwordLeastCharacter = "The password must be at least `n` characters.";
9 | public static String firstNameLeastCharacter = "The password must be at least `n` characters.";
10 | public static String lastNameLeastCharacter = "The password must be at least `n` characters.";
11 | public static String emailNotValid = "Not a valid e-mail address";
12 | public static String emailAlreadyExists = "E-mail already exists.";
13 |
14 | public static String userActivated = "User has just activated, you can login now.";
15 | public static String activationCodeNotFound = "Activation code not found.";
16 | public static String googleSignUpSuccessful = "Google Sign-Up authentication Successful";
17 | public static String googleSignUpFailed = "Google Sign-Up authentication Failed";
18 | public static String userLoggedIn = "User logged in.";
19 | public static String userEmailOrPasswordNotFound = "Email or Password not found.";
20 | public static String needActivateUser = "You need activate the user.";
21 | }
22 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/crud/BaseCrud.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.crud;
2 |
3 | import java.util.List;
4 | import java.util.function.Predicate;
5 |
6 | public interface BaseCrud {
7 | void add(T entity);
8 | void update(T entity);
9 | void delete(T entity);
10 | T get(Predicate predicate);
11 | List getAll();
12 | List getAll(Predicate predicate);
13 | }
14 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/result/ErrorResult.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.result;
2 |
3 | public class ErrorResult extends Result {
4 |
5 | public ErrorResult() {
6 | super(false);
7 | }
8 |
9 | public ErrorResult(String message) {
10 | super(false, message);
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/result/Result.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.result;
2 |
3 | public class Result {
4 | private final boolean success;
5 | private String message;
6 |
7 | public Result(boolean success) {
8 | this.success = success;
9 | }
10 |
11 | public Result(boolean success, String message) {
12 | this(success);
13 | this.message = message;
14 | }
15 |
16 | public String getMessage() {
17 | return message;
18 | }
19 |
20 | public boolean isSuccess() {
21 | return success;
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/result/SuccessResult.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.result;
2 |
3 | public class SuccessResult extends Result {
4 | public SuccessResult() {
5 | super(true);
6 | }
7 |
8 | public SuccessResult(String message) {
9 | super(true, message);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/security/signUp/SignUpService.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.security.signUp;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface SignUpService {
6 | void register(User user);
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/Sendable.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable;
2 |
3 | public interface Sendable {
4 | void send(String to, String message);
5 | }
6 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/SendableUtils.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable;
2 |
3 | import homework.core.utils.sendable.mail.Mail;
4 | import homework.core.utils.sendable.sms.Sms;
5 |
6 | public class SendableUtils {
7 |
8 | public static void run(Sendable sendable, Mail mail) {
9 | sendable.send(mail.getMailAddress(), mail.getMessage());
10 | }
11 | public static void run(Sendable sendable, Sms sms) {
12 | sendable.send(sms.getPhoneNumber(), sms.getMessage());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/mail/CustomMailManager.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.mail;
2 |
3 | public class CustomMailManager implements MailService{
4 |
5 | @Override
6 | public void send(String to, String message) {
7 | System.out.println("MAIL --> `" + message + "` sended to : " + to);
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/mail/Mail.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.mail;
2 |
3 | public class Mail {
4 | private String mailAddress;
5 | private String message;
6 |
7 | public Mail() {
8 |
9 | }
10 |
11 | public Mail(String mailAddress, String message) {
12 | super();
13 | this.mailAddress = mailAddress;
14 | this.message = message;
15 | }
16 |
17 | public String getMailAddress() {
18 | return mailAddress;
19 | }
20 |
21 | public void setMailAddress(String mailAddress) {
22 | this.mailAddress = mailAddress;
23 | }
24 |
25 | public String getMessage() {
26 | return message;
27 | }
28 |
29 | public void setMessage(String message) {
30 | this.message = message;
31 | }
32 |
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/mail/MailService.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.mail;
2 |
3 | import homework.core.utils.sendable.Sendable;
4 |
5 | public interface MailService extends Sendable{
6 | }
7 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/sms/CustomSmsManager.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.sms;
2 |
3 | public class CustomSmsManager implements SmsService{
4 |
5 | @Override
6 | public void send(String to, String message) {
7 | System.out.println("SMS --> `" + message + "` sended to : " + to);
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/sms/Sms.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.sms;
2 |
3 | public class Sms {
4 | private String phoneNumber;
5 | private String message;
6 |
7 | public Sms() {
8 |
9 | }
10 |
11 | public Sms(String phoneNumber, String message) {
12 | super();
13 | this.phoneNumber = phoneNumber;
14 | this.message = message;
15 | }
16 |
17 | public String getPhoneNumber() {
18 | return phoneNumber;
19 | }
20 |
21 | public void setPhoneNumber(String phoneNumber) {
22 | this.phoneNumber = phoneNumber;
23 | }
24 |
25 | public String getMessage() {
26 | return message;
27 | }
28 |
29 | public void setMessage(String message) {
30 | this.message = message;
31 | }
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/core/utils/sendable/sms/SmsService.java:
--------------------------------------------------------------------------------
1 | package homework.core.utils.sendable.sms;
2 |
3 | import homework.core.utils.sendable.Sendable;
4 |
5 | public interface SmsService extends Sendable{
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/dataAccess/abstracts/Dao.java:
--------------------------------------------------------------------------------
1 | package homework.dataAccess.abstracts;
2 |
3 | import homework.core.utils.crud.BaseCrud;
4 |
5 | public interface Dao extends BaseCrud {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/dataAccess/abstracts/UserActivationDao.java:
--------------------------------------------------------------------------------
1 | package homework.dataAccess.abstracts;
2 |
3 | import homework.entity.concretes.UserActivation;
4 |
5 | public interface UserActivationDao extends Dao{
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/dataAccess/abstracts/UserDao.java:
--------------------------------------------------------------------------------
1 | package homework.dataAccess.abstracts;
2 |
3 | import homework.entity.concretes.User;
4 |
5 | public interface UserDao extends Dao{
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/dataAccess/concretes/inMemory/InMemoryUserActivationDao.java:
--------------------------------------------------------------------------------
1 | package homework.dataAccess.concretes.inMemory;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.function.Predicate;
6 | import java.util.stream.Collectors;
7 |
8 | import homework.dataAccess.abstracts.UserActivationDao;
9 | import homework.entity.concretes.UserActivation;
10 |
11 | public class InMemoryUserActivationDao implements UserActivationDao{
12 |
13 | private List userActivationArrayList;
14 |
15 | public InMemoryUserActivationDao() {
16 | this.userActivationArrayList = new ArrayList();
17 | }
18 |
19 | @Override
20 | public void add(UserActivation userActivation) {
21 | this.userActivationArrayList.add(userActivation);
22 | }
23 |
24 | @Override
25 | public void update(UserActivation userActivation) {
26 | this.userActivationArrayList.set(
27 | this.userActivationArrayList.indexOf(userActivation),
28 | userActivation
29 | );
30 | }
31 |
32 | @Override
33 | public void delete(UserActivation userActivation) {
34 | this.userActivationArrayList.remove(
35 | this.userActivationArrayList.indexOf(userActivation)
36 | );
37 | }
38 |
39 | @Override
40 | public UserActivation get(Predicate predicate) {
41 | return this.userActivationArrayList.stream().filter(predicate).findFirst().orElse(null);
42 | }
43 |
44 | @Override
45 | public List getAll() {
46 | return this.userActivationArrayList.stream().collect(Collectors.toList());
47 | }
48 |
49 | @Override
50 | public List getAll(Predicate predicate) {
51 | return this.userActivationArrayList.stream().filter(predicate).collect(Collectors.toList());
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/dataAccess/concretes/inMemory/InMemoryUserDao.java:
--------------------------------------------------------------------------------
1 | package homework.dataAccess.concretes.inMemory;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.function.Predicate;
6 | import java.util.stream.Collectors;
7 |
8 | import homework.dataAccess.abstracts.UserDao;
9 | import homework.entity.concretes.User;
10 |
11 | public class InMemoryUserDao implements UserDao {
12 |
13 | private List userArrayList;
14 |
15 | public InMemoryUserDao() {
16 | this.userArrayList = new ArrayList();
17 | }
18 |
19 | @Override
20 | public void add(User user) {
21 | this.userArrayList.add(user);
22 | }
23 |
24 | @Override
25 | public void update(User user) {
26 | this.userArrayList.set(
27 | this.userArrayList.indexOf(user),
28 | user
29 | );
30 | }
31 |
32 | @Override
33 | public void delete(User user) {
34 | this.userArrayList.remove(
35 | this.userArrayList.indexOf(user)
36 | );
37 | }
38 |
39 | @Override
40 | public User get(Predicate predicate) {
41 | return this.userArrayList.stream().filter(predicate).findFirst().orElse(null);
42 | }
43 |
44 | @Override
45 | public List getAll() {
46 | return this.userArrayList.stream().collect(Collectors.toList());
47 | }
48 |
49 | @Override
50 | public List getAll(Predicate predicate) {
51 | return this.userArrayList.stream().filter(predicate).collect(Collectors.toList());
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/entity/concretes/User.java:
--------------------------------------------------------------------------------
1 | package homework.entity.concretes;
2 |
3 | import homework.core.dataAccess.abstracts.Entity;
4 |
5 | public class User implements Entity{
6 | private int id;
7 | private String firstName;
8 | private String lastName;
9 | private String email;
10 | private String password;
11 | private String phoneNumber;
12 | private boolean isActive;
13 |
14 | public User() {
15 | }
16 |
17 |
18 | public User(int id, String firstName, String lastName, String email, String password, String phoneNumber) {
19 | this.id = id;
20 | this.firstName = firstName;
21 | this.lastName = lastName;
22 | this.email = email;
23 | this.password = password;
24 | this.phoneNumber = phoneNumber;
25 | }
26 |
27 | public int getId() {
28 | return id;
29 | }
30 | public void setId(int id) {
31 | this.id = id;
32 | }
33 |
34 | public String getFirstName() {
35 | return firstName;
36 | }
37 | public void setFirstName(String firstName) {
38 | this.firstName = firstName;
39 | }
40 |
41 | public String getLastName() {
42 | return lastName;
43 | }
44 | public void setLastName(String lastName) {
45 | this.lastName = lastName;
46 | }
47 |
48 | public String getEmail() {
49 | return email;
50 | }
51 | public void setEmail(String email) {
52 | this.email = email;
53 | }
54 |
55 | public String getPassword() {
56 | return password;
57 | }
58 |
59 | public void setPassword(String password) {
60 | this.password = password;
61 | }
62 |
63 | public String getPhoneNumber() {
64 | return phoneNumber;
65 | }
66 |
67 | public void setPhoneNumber(String phoneNumber) {
68 | this.phoneNumber = phoneNumber;
69 | }
70 |
71 | public boolean isActive() {
72 | return isActive;
73 | }
74 |
75 | public void setActive(boolean isActive) {
76 | this.isActive = isActive;
77 | }
78 |
79 | @Override
80 | public String toString() {
81 | return "{\"id\": " + id + ", \"firstName\": \"" + firstName + "\", \"lastName\": \"" + lastName + "\", \"email\": \"" + email
82 | + "\", \"password\": \"" + password + "\", isActive: " + isActive + "}";
83 | }
84 |
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/entity/concretes/UserActivation.java:
--------------------------------------------------------------------------------
1 | package homework.entity.concretes;
2 |
3 | import homework.core.dataAccess.abstracts.Entity;
4 |
5 | public class UserActivation implements Entity {
6 | private int id;
7 | private int userId;
8 | private String activationCode;
9 |
10 | public UserActivation() {
11 |
12 | }
13 |
14 | public UserActivation(int id, int userId, String activationCode) {
15 | super();
16 | this.id = id;
17 | this.userId = userId;
18 | this.activationCode = activationCode;
19 | }
20 |
21 | public int getId() {
22 | return id;
23 | }
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 | public int getUserId() {
28 | return userId;
29 | }
30 | public void setUserId(int userId) {
31 | this.userId = userId;
32 | }
33 | public String getActivationCode() {
34 | return activationCode;
35 | }
36 | public void setActivationCode(String activationCode) {
37 | this.activationCode = activationCode;
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/lecture5.2-homework/src/homework/googleAuth/GoogleSignUpManager.java:
--------------------------------------------------------------------------------
1 | package homework.googleAuth;
2 |
3 | public class GoogleSignUpManager {
4 | public boolean login(String email) {
5 | return true;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karcan/javaBootcamp/0268859a931df7b560d823427eaade2697eca4ef/lecture6.1-springIntro/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/lecture6.1-springIntro/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/NorthwindApplication.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class NorthwindApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(NorthwindApplication.class, args);
11 |
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/api/controllers/ProductsController.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind.api.controllers;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | import kodlamaio.northwind.business.abstracts.ProductService;
11 | import kodlamaio.northwind.entity.concretes.Product;
12 |
13 | @RestController
14 | @RequestMapping("/api/products")
15 | public class ProductsController {
16 | private final ProductService productService;
17 |
18 | @Autowired
19 | public ProductsController(ProductService productService) {
20 | super();
21 | this.productService = productService;
22 | }
23 |
24 | @GetMapping("/getall")
25 | public List getAll(){
26 |
27 | return this.productService.getAll();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/business/abstracts/ProductService.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind.business.abstracts;
2 |
3 | import java.util.List;
4 |
5 | import kodlamaio.northwind.entity.concretes.Product;
6 |
7 | public interface ProductService {
8 | List getAll();
9 | }
10 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/business/concretes/ProductManager.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind.business.concretes;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import kodlamaio.northwind.business.abstracts.ProductService;
9 | import kodlamaio.northwind.dataAccess.abstracts.ProductDao;
10 | import kodlamaio.northwind.entity.concretes.Product;
11 |
12 | @Service
13 | public class ProductManager implements ProductService {
14 |
15 | private ProductDao productDao;
16 |
17 | @Autowired
18 | public ProductManager(ProductDao productDao) {
19 | super();
20 | this.productDao = productDao;
21 | }
22 |
23 | @Override
24 | public List getAll() {
25 | return this.productDao.findAll();
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/dataAccess/abstracts/ProductDao.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind.dataAccess.abstracts;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 |
5 | import kodlamaio.northwind.entity.concretes.Product;
6 |
7 | public interface ProductDao extends JpaRepository {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/java/kodlamaio/northwind/entity/concretes/Product.java:
--------------------------------------------------------------------------------
1 | package kodlamaio.northwind.entity.concretes;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.Id;
7 | import javax.persistence.Table;
8 |
9 | import lombok.Data;
10 |
11 | @Data
12 | @Entity
13 | @Table(name="products")
14 | public class Product {
15 | @Id
16 | @GeneratedValue
17 | @Column(name="product_id")
18 | private int id;
19 |
20 | @Column(name="category_id")
21 | private int categoryId;
22 |
23 | @Column(name="product_name")
24 | private String productName;
25 |
26 | @Column(name="unit_price")
27 | private double unitPrice;
28 |
29 | @Column(name="units_in_stock")
30 | private short unitsInStock;
31 |
32 | @Column(name="quantity_per_unit")
33 | private String quantityPerUnit;
34 | }
35 |
--------------------------------------------------------------------------------
/lecture6.1-springIntro/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
2 | spring.jpa.hibernate.ddl-auto=update
3 | spring.jpa.hibernate.show-sql=true
4 | spring.datasource.url=jdbc:postgresql://192.168.1.150:5432/northwind
5 | spring.datasource.username=postgres
6 | spring.datasource.password=Karcan*
7 | spring.jpa.properties.javax.persistence.validation.mode = none
8 |
9 |
10 |