1
0
forked from s434786/DINO_SCRUM

add update product and omitted validation

This commit is contained in:
prgres 2019-01-22 03:16:40 +01:00
parent c2badfe536
commit d84674c637
8 changed files with 271 additions and 156 deletions

11
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="heroku" uuid="4eb55351-864c-4d3f-b24d-048a158530c7">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://ec2-54-75-230-41.eu-west-1.compute.amazonaws.com:5432/d3e1jrm08qe91q?ssl=true&amp;sslmode=require&amp;amp=org.postgresql.ssl.NonValidatingFactory</jdbc-url>
</data-source>
</component>
</project>

View File

@ -1,20 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="2dc093a7-8382-4e31-b457-ce6c9fd10d13" name="Default Changelist" comment=""> <list default="true" id="2dc093a7-8382-4e31-b457-ce6c9fd10d13" name="Default Changelist" comment="added quantityChange validation, product validation, checking existing object in db, throwing exeption">
<change afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/exception/ProductNotFoundException.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" />
</list> </list>
<ignored path="$PROJECT_DIR$/target/" /> <ignored path="$PROJECT_DIR$/target/" />
@ -35,32 +28,87 @@
<option name="HIDDEN_KINDS"> <option name="HIDDEN_KINDS">
<set /> <set />
</option> </option>
<expand /> <expand>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
<item name="tables" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
<item name="tables" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="product: table" type="69fad909:PgImplModel$LocalTable" />
</path>
</expand>
<select /> <select />
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<splitter split-orientation="horizontal" split-proportion="0.5"> <leaf>
<split-first> <file pinned="false" current-in-tab="false">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-75"> <state relative-caret-position="456">
<caret line="22" column="18" selection-start-line="22" selection-start-column="18" selection-end-line="22" selection-end-column="18" /> <caret line="83" column="84" selection-start-line="83" selection-start-column="84" selection-end-line="83" selection-end-column="84" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#1394#1395#0" expanded="true" />
<element signature="e#1489#1490#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false">
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="64">
<caret line="48" column="14" lean-forward="true" selection-start-line="48" selection-start-column="14" selection-end-line="48" selection-end-column="14" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-70"> <state relative-caret-position="510">
<caret line="23" column="4" selection-start-line="23" selection-start-column="4" selection-end-line="23" selection-end-column="4" /> <caret line="83" column="68" selection-start-line="83" selection-start-column="68" selection-end-line="83" selection-end-column="68" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -69,51 +117,24 @@
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240"> <state relative-caret-position="75">
<caret line="16" column="28" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" /> <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="10" column="10" selection-start-line="10" selection-start-column="10" selection-end-line="10" selection-end-column="10" />
</state>
</provider>
</entry>
</file>
</leaf>
</split-first>
<split-second>
<leaf>
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java"> <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="225">
<caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" /> <caret line="15" selection-start-line="15" selection-end-line="15" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#438#439#0" expanded="true" />
<element signature="e#496#497#0" expanded="true" />
<element signature="e#234#235#0" expanded="true" />
<element signature="e#289#290#0" expanded="true" />
<element signature="e#351#352#0" expanded="true" />
<element signature="e#410#411#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
</leaf> </leaf>
</split-second>
</splitter>
</component> </component>
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
@ -143,18 +164,19 @@
<list> <list>
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/HomeController.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/HomeController.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/MainController.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/MainController.java" />
<option value="$PROJECT_DIR$/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/exception/ProductNotFoundException.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/exception/ProductNotFoundException.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/QuantityChangeValidator.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/QuantityChangeValidator.java" />
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" />
<option value="$PROJECT_DIR$/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" />
<option value="$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" /> <option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" />
</list> </list>
</option> </option>
</component> </component>
@ -299,13 +321,14 @@
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="DatabaseDriversLRU" value="h2" /> <property name="DatabaseDriversLRU" value="h2&#10;postgresql" />
<property name="RequestMappingsPanelOrder0" value="0" /> <property name="RequestMappingsPanelOrder0" value="0" />
<property name="RequestMappingsPanelOrder1" value="1" /> <property name="RequestMappingsPanelOrder1" value="1" />
<property name="RequestMappingsPanelWidth0" value="75" /> <property name="RequestMappingsPanelWidth0" value="75" />
<property name="RequestMappingsPanelWidth1" value="75" /> <property name="RequestMappingsPanelWidth1" value="75" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
<property name="database.console.LAST_STATE" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@ -379,16 +402,23 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1547322958782</updated> <updated>1547322958782</updated>
<workItem from="1547322960420" duration="21872000" /> <workItem from="1547322960420" duration="21872000" />
<workItem from="1547401179909" duration="28165000" /> <workItem from="1547401179909" duration="29998000" />
</task> </task>
<task id="LOCAL-00001" summary="added quantityChange validation, product validation, checking existing object in db, throwing exeption">
<created>1548121370553</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1548121370553</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="50037000" /> <option name="totallyTimeSpent" value="51870000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1680" height="1027" extended-state="6" /> <frame x="0" y="23" width="1680" height="1027" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.49810606" visible="true" weight="0.17948718" /> <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.49810606" visible="true" weight="0.17948718" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
@ -396,9 +426,10 @@
<window_info id="UI Designer" order="3" /> <window_info id="UI Designer" order="3" />
<window_info id="Favorites" order="4" side_tool="true" /> <window_info id="Favorites" order="4" side_tool="true" />
<window_info id="Web" order="5" sideWeight="0.50189394" side_tool="true" weight="0.36842105" /> <window_info id="Web" order="5" sideWeight="0.50189394" side_tool="true" weight="0.36842105" />
<window_info anchor="bottom" id="Database Console" sideWeight="0.498779" weight="0.5893048" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" sideWeight="0.498779" weight="0.32941177" /> <window_info anchor="bottom" id="Find" order="1" sideWeight="0.498779" weight="0.32941177" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.498779" weight="0.3315508" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.498779" visible="true" weight="0.3315508" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@ -406,7 +437,7 @@
<window_info anchor="bottom" id="Spring" order="7" sideWeight="0.4993895" weight="0.32941177" /> <window_info anchor="bottom" id="Spring" order="7" sideWeight="0.4993895" weight="0.32941177" />
<window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.498779" weight="0.20855615" /> <window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.498779" weight="0.20855615" />
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.501221" side_tool="true" weight="0.32941177" /> <window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.501221" side_tool="true" weight="0.5893048" />
<window_info anchor="bottom" id="Messages" order="11" weight="0.32941177" /> <window_info anchor="bottom" id="Messages" order="11" weight="0.32941177" />
<window_info anchor="bottom" id="Java Enterprise" order="12" /> <window_info anchor="bottom" id="Java Enterprise" order="12" />
<window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" /> <window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" />
@ -417,7 +448,7 @@
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Maven" order="3" weight="0.32967034" /> <window_info anchor="right" id="Maven" order="3" weight="0.32967034" />
<window_info anchor="right" id="Palette" order="4" /> <window_info anchor="right" id="Palette" order="4" />
<window_info anchor="right" id="Database" order="5" weight="0.32967034" /> <window_info anchor="right" id="Database" order="5" weight="0.6466165" />
<window_info anchor="right" id="Palette&#9;" order="6" /> <window_info anchor="right" id="Palette&#9;" order="6" />
<window_info anchor="right" id="Bean Validation" order="7" /> <window_info anchor="right" id="Bean Validation" order="7" />
</layout> </layout>
@ -470,6 +501,11 @@
<path value="$PROJECT_DIR$" /> <path value="$PROJECT_DIR$" />
<path value="$PROJECT_DIR$/DINO_SCRUM" /> <path value="$PROJECT_DIR$/DINO_SCRUM" />
</ignored-roots> </ignored-roots>
<MESSAGE value="added quantityChange validation, product validation, checking existing object in db, throwing exeption" />
<option name="LAST_COMMIT_MESSAGE" value="added quantityChange validation, product validation, checking existing object in db, throwing exeption" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.1.2.RELEASE/spring-boot-autoconfigure-2.1.2.RELEASE.jar!/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.class"> <entry file="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.1.2.RELEASE/spring-boot-autoconfigure-2.1.2.RELEASE.jar!/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.class">
@ -486,13 +522,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="16" lean-forward="true" selection-start-line="16" selection-end-line="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150"> <state relative-caret-position="150">
@ -551,16 +580,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="16" column="28" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="195">
@ -571,41 +590,12 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java"> <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/d0158af3-b28d-407c-b7c8-7331568f6f97/console.sql">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor" />
<state relative-caret-position="-70">
<caret line="23" column="4" selection-start-line="23" selection-start-column="4" selection-end-line="23" selection-end-column="4" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-75">
<caret line="22" column="18" selection-start-line="22" selection-start-column="18" selection-end-line="22" selection-end-column="18" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1394#1395#0" expanded="true" />
<element signature="e#1489#1490#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="15" column="7" lean-forward="true" selection-start-line="15" selection-start-column="7" selection-end-line="15" selection-end-column="7" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="-5">
<caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" /> <caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
@ -619,6 +609,67 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="64">
<caret line="48" column="14" lean-forward="true" selection-start-line="48" selection-start-column="14" selection-end-line="48" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="43" selection-start-line="20" selection-start-column="43" selection-end-line="20" selection-end-column="43" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="588">
<caret line="45" column="25" lean-forward="true" selection-start-line="45" selection-start-column="25" selection-end-line="45" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="83" column="68" selection-start-line="83" selection-start-column="68" selection-end-line="83" selection-end-column="68" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="456">
<caret line="83" column="84" selection-start-line="83" selection-start-column="84" selection-end-line="83" selection-end-column="84" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
</component> </component>
<component name="masterDetails"> <component name="masterDetails">
<states> <states>

View File

@ -4,10 +4,12 @@ import com.dino.scrum.sysmag.model.Product;
import com.dino.scrum.sysmag.model.dto.IdDto; import com.dino.scrum.sysmag.model.dto.IdDto;
import com.dino.scrum.sysmag.model.dto.QuantityChange; import com.dino.scrum.sysmag.model.dto.QuantityChange;
import com.dino.scrum.sysmag.service.ProductServiceImpl; import com.dino.scrum.sysmag.service.ProductServiceImpl;
import com.dino.scrum.sysmag.validationGroup.UpdateGroup;
import com.dino.scrum.sysmag.validator.QuantityChangeValidator; import com.dino.scrum.sysmag.validator.QuantityChangeValidator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
@ -75,6 +77,15 @@ public class ProductController {
} }
} }
@PostMapping(value = "/product/update/{id}")
public Product update(@Validated(UpdateGroup.class) @RequestBody Product product, @PathVariable("id") long id) {
try {
return productService.update(product, id);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@PostMapping(value = "/product/change-quantity") @PostMapping(value = "/product/change-quantity")
public public
Product changeQuantity(@RequestBody QuantityChange quantityChange){ Product changeQuantity(@RequestBody QuantityChange quantityChange){

View File

@ -18,6 +18,8 @@ public interface ProductService {
Product add(Product product) throws Exception; Product add(Product product) throws Exception;
Product update(Product product, long id) throws Exception;
float getPriceOfAll(); float getPriceOfAll();
void delete(long id) throws Exception; void delete(long id) throws Exception;

View File

@ -71,6 +71,32 @@ public class ProductServiceImpl implements ProductService {
return productRepository.save(product); return productRepository.save(product);
} }
@Override
public Product update(Product productReceived, long id) throws Exception {
productValidator.checkIfExists(productReceived.getId());
Product productToChange = productRepository.findById(id);
if (productReceived.getName() != null)
productToChange.setName(productReceived.getName());
if (productReceived.getName() != null)
productToChange.setPrice(productReceived.getPrice());
if (productReceived.getName() != null)
productToChange.setQuantity(productReceived.getQuantity());
if (productReceived.getName() != null)
productToChange.setQuantityMax(productReceived.getQuantityMax());
if (productReceived.getName() != null)
productToChange.setImageLink(productReceived.getImageLink());
productRepository.save(productToChange);
return productRepository.findById(productToChange.getId().longValue());
}
@Override @Override
public void delete(long id) throws Exception { public void delete(long id) throws Exception {
productValidator.checkIfExists(id); productValidator.checkIfExists(id);

View File

@ -0,0 +1,8 @@
package com.dino.scrum.sysmag.validationGroup;
/**
* Created by prgres on 2019-01-22.
*/
public interface UpdateGroup {
}

View File

@ -7,7 +7,7 @@ spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.generate-ddl=true spring.jpa.generate-ddl=true
spring.jpa.show-sql=false spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

View File

@ -1,10 +1,16 @@
# H2 # Details for our datasource heroku
spring.h2.console.enabled=true spring.datasource.url=jdbc:postgresql://ec2-54-75-230-41.eu-west-1.compute.amazonaws.com/d3e1jrm08qe91q?ssl=true&sslmode=require&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory
spring.h2.console.path=/h2 spring.datasource.username=eecsegponwphcn
spring.jpa.hibernate.ddl-auto=create spring.datasource.password=4045a1e5a2de22362149709c3a2a1d5eb6e243cd553fd1a15f76fc54923638ce
spring.datasource.driverClassName=org.postgresql.Driver
# Hibernate properties
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.generate-ddl=true spring.jpa.generate-ddl=true
# Datasource spring.jpa.show-sql=false
spring.datasource.url=jdbc:h2:file:~/sysmag spring.jpa.hibernate.ddl-auto=update
spring.datasource.username=sa spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.datasource.password= spring.jpa.properties.hibernate.format_sql=true
spring.datasource.driver-class-name=org.h2.Driver spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
#spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false