Revize c0e44337
Přidáno uživatelem Jiri Trefil před téměř 2 roky(ů)
db/spade-configurations.sql | ||
---|---|---|
1 |
use [authspade]; |
|
2 |
begin transaction create_enviroment |
|
3 |
if not exists (select * from sysobjects where name='configurations' and xtype='U') |
|
4 |
create table configurations ( |
|
5 |
id int identity(1, 1), |
|
6 |
configHash nvarchar(255), |
|
7 |
config nvarchar(max) not null, |
|
8 |
isDefault char(1) not null, |
|
9 |
PRIMARY KEY(id) |
|
10 |
); |
|
11 |
|
|
12 |
if not exists (select * from sysobjects where name='users' and xtype='U') |
|
13 |
create table users( |
|
14 |
id int identity(1,1), |
|
15 |
email nvarchar(255) not null, |
|
16 |
name nvarchar(255) not null, |
|
17 |
password varchar(255) not null |
|
18 |
PRIMARY KEY(id) |
|
19 |
); |
|
20 |
|
|
21 |
|
|
22 |
--rozkladova tabulka mapujici uzivatele a k nemu asociovane konfigurace |
|
23 |
if not exists (select * from sysobjects where name='user_configurations' and xtype='U') |
|
24 |
create table user_configurations ( |
|
25 |
userId int not null, |
|
26 |
configId int not null, |
|
27 |
foreign key(userId) references users(id), |
|
28 |
foreign key(configId) references configurations(id), |
|
29 |
primary key(userId,configId) |
|
30 |
) |
|
31 |
|
|
32 |
insert into configurations (config, isDefault) values ( |
|
33 |
'{ |
|
34 |
"configuration": [ |
|
35 |
{ |
|
36 |
"antiPattern": "TooLongSprint", |
|
37 |
"thresholds": [ |
|
38 |
{ |
|
39 |
"thresholdName": "maxIterationLength", |
|
40 |
"value": "21" |
|
41 |
}, |
|
42 |
{ |
|
43 |
"thresholdName": "maxNumberOfTooLongIterations", |
|
44 |
"value": "0" |
|
45 |
} |
|
46 |
] |
|
47 |
}, |
|
48 |
{ |
|
49 |
"antiPattern": "VaryingSprintLength", |
|
50 |
"thresholds": [ |
|
51 |
{ |
|
52 |
"thresholdName": "maxDaysDifference", |
|
53 |
"value": "7" |
|
54 |
}, |
|
55 |
{ |
|
56 |
"thresholdName": "maxIterationChanged", |
|
57 |
"value": "1" |
|
58 |
} |
|
59 |
] |
|
60 |
}, |
|
61 |
{ |
|
62 |
"antiPattern": "BusinessAsUsual", |
|
63 |
"thresholds": [ |
|
64 |
{ |
|
65 |
"thresholdName": "divisionOfIterationsWithRetrospective", |
|
66 |
"value": "66.66f" |
|
67 |
}, |
|
68 |
{ |
|
69 |
"thresholdName": "searchSubstringsWithRetrospective", |
|
70 |
"value": "%retr%||%revi%||%week%scrum%" |
|
71 |
} |
|
72 |
] |
|
73 |
}, |
|
74 |
{ |
|
75 |
"antiPattern": "SpecifyNothing", |
|
76 |
"thresholds": [ |
|
77 |
{ |
|
78 |
"thresholdName": "minNumberOfWikiPagesWithSpecification", |
|
79 |
"value": "1" |
|
80 |
}, |
|
81 |
{ |
|
82 |
"thresholdName": "minNumberOfActivitiesWithSpecification", |
|
83 |
"value": "1" |
|
84 |
}, |
|
85 |
{ |
|
86 |
"thresholdName": "minAvgLengthOfActivityDescription", |
|
87 |
"value": "150" |
|
88 |
}, |
|
89 |
{ |
|
90 |
"thresholdName": "searchSubstringsWithProjectSpecification", |
|
91 |
"value": "%dsp%||%specifikace%||%specification%||%vize%proj%||%vize%produ%" |
|
92 |
} |
|
93 |
] |
|
94 |
}, |
|
95 |
{ |
|
96 |
"antiPattern": "RoadToNowhere", |
|
97 |
"thresholds": [ |
|
98 |
{ |
|
99 |
"thresholdName": "minNumberOfWikiPagesWithProjectPlan", |
|
100 |
"value": "1" |
|
101 |
}, |
|
102 |
{ |
|
103 |
"thresholdName": "minNumberOfActivitiesWithProjectPlan", |
|
104 |
"value": "1" |
|
105 |
}, |
|
106 |
{ |
|
107 |
"thresholdName": "searchSubstringsWithProjectPlan", |
|
108 |
"value": "%pl?n projektu%||%project plan%||%plan project%||%projektov? pl?n%" |
|
109 |
} |
|
110 |
] |
|
111 |
}, |
|
112 |
{ |
|
113 |
"antiPattern": "LongOrNonExistentFeedbackLoops", |
|
114 |
"thresholds": [ |
|
115 |
{ |
|
116 |
"thresholdName": "divisionOfIterationsWithFeedbackLoop", |
|
117 |
"value": "50.00f" |
|
118 |
}, |
|
119 |
{ |
|
120 |
"thresholdName": "maxGapBetweenFeedbackLoopRate", |
|
121 |
"value": "2f" |
|
122 |
}, |
|
123 |
{ |
|
124 |
"thresholdName": "searchSubstringsWithFeedbackLoop", |
|
125 |
"value": "%sch?z%z?kazn?k%||%p?edveden?%z?kazn?k%||%z?kazn%demo%||%sch?z%zadavat%||%inform%sch?z%||%z?kazn%||%zadavatel%" |
|
126 |
} |
|
127 |
] |
|
128 |
}, |
|
129 |
{ |
|
130 |
"antiPattern": "NinetyNinetyRule", |
|
131 |
"thresholds": [ |
|
132 |
{ |
|
133 |
"thresholdName": "maxDivisionRange", |
|
134 |
"value": "1.25f" |
|
135 |
}, |
|
136 |
{ |
|
137 |
"thresholdName": "maxBadDivisionLimit", |
|
138 |
"value": "2" |
|
139 |
} |
|
140 |
] |
|
141 |
}, |
|
142 |
{ |
|
143 |
"antiPattern": "UnknownPoster", |
|
144 |
"thresholds": [ |
|
145 |
{ |
|
146 |
"thresholdName": "searchSubstringsInvalidNames", |
|
147 |
"value": "%unknown%||%anonym%" |
|
148 |
} |
|
149 |
] |
|
150 |
}, |
|
151 |
{ |
|
152 |
"antiPattern": "BystanderApathy", |
|
153 |
"thresholds": [ |
|
154 |
{ |
|
155 |
"thresholdName": "searchSubstringsInvalidContributors", |
|
156 |
"value": "%dependabot%" |
|
157 |
}, |
|
158 |
{ |
|
159 |
"thresholdName": "maximumPercentageOfTasksWithoutTeamwork", |
|
160 |
"value": "30f" |
|
161 |
} |
|
162 |
] |
|
163 |
}, |
|
164 |
{ |
|
165 |
"antiPattern": "YetAnotherProgrammer", |
|
166 |
"thresholds": [ |
|
167 |
{ |
|
168 |
"thresholdName": "maxNumberOfNewContributors", |
|
169 |
"value": "5" |
|
170 |
}, |
|
171 |
{ |
|
172 |
"thresholdName": "numberOfFirstMonthsWithoutDetection", |
|
173 |
"value": "2" |
|
174 |
} |
|
175 |
] |
|
176 |
} |
|
177 |
] |
|
178 |
}', |
|
179 |
'Y' |
|
180 |
|
|
181 |
|
|
182 |
) |
|
183 |
|
|
184 |
commit |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/ConfigurationController.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.controller; |
|
2 |
|
|
3 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration; |
|
4 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User; |
|
5 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey; |
|
6 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfiguration; |
|
7 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserConfigurationRepository; |
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
import org.springframework.web.bind.annotation.GetMapping; |
|
10 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
11 |
import org.springframework.web.bind.annotation.RestController; |
|
12 |
|
|
13 |
/** |
|
14 |
* @Author Jiri Trefil |
|
15 |
* Controller providing API for configuration management |
|
16 |
*/ |
|
17 |
@RestController |
|
18 |
@RequestMapping("v2/configuration") |
|
19 |
public class ConfigurationController { |
|
20 |
@Autowired |
|
21 |
private UserConfigurationRepository userConfigurationRepository ; |
|
22 |
|
|
23 |
@GetMapping(value="/test") |
|
24 |
public String test(){ |
|
25 |
UserConfigKey key = new UserConfigKey(1,1); |
|
26 |
UserConfiguration tmp = userConfigurationRepository.save(new UserConfiguration(key)); |
|
27 |
return "test"; |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/Configuration.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
import javax.persistence.*; |
|
4 |
|
|
5 |
@Entity |
|
6 |
@Table(name="configuration") |
|
7 |
public class Configuration { |
|
8 |
@Id |
|
9 |
@GeneratedValue(strategy = GenerationType.IDENTITY) |
|
10 |
private int id; |
|
11 |
//configuration json file |
|
12 |
private String config; |
|
13 |
//hash of the configuration so users cant upload duplicates |
|
14 |
private String configHash; |
|
15 |
// 'Y' if the configuration is accessible to everyone, 'N' if its user defined |
|
16 |
private char isDefault; |
|
17 |
|
|
18 |
public Configuration(){} |
|
19 |
public Configuration(String config, String configHash, boolean isDefault){ |
|
20 |
this.config = config; |
|
21 |
this.configHash = configHash; |
|
22 |
this.isDefault = isDefault?'Y':'N'; |
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
public int getId() { |
|
27 |
return id; |
|
28 |
} |
|
29 |
|
|
30 |
public String getConfig() { |
|
31 |
return config; |
|
32 |
} |
|
33 |
|
|
34 |
public String getConfigHash() { |
|
35 |
return configHash; |
|
36 |
} |
|
37 |
|
|
38 |
public char getIsDefault() { |
|
39 |
return isDefault; |
|
40 |
} |
|
41 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/User.java | ||
---|---|---|
28 | 28 |
*/ |
29 | 29 |
@Id |
30 | 30 |
@GeneratedValue(strategy = GenerationType.IDENTITY) |
31 |
private Long id;
|
|
31 |
private int id;
|
|
32 | 32 |
|
33 | 33 |
/** |
34 | 34 |
* Name of the User |
... | ... | |
67 | 67 |
* Getter of id |
68 | 68 |
* @return id of the user |
69 | 69 |
*/ |
70 |
public Long getId() {
|
|
70 |
public int getId() {
|
|
71 | 71 |
return id; |
72 | 72 |
} |
73 | 73 |
|
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigKey.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
import javax.persistence.Embeddable; |
|
4 |
import java.io.Serializable; |
|
5 |
|
|
6 |
@Embeddable |
|
7 |
public class UserConfigKey implements Serializable { |
|
8 |
|
|
9 |
private int userId; |
|
10 |
private int configId; |
|
11 |
|
|
12 |
public UserConfigKey(int userId,int configId){ |
|
13 |
this.userId = userId; |
|
14 |
this.configId = configId; |
|
15 |
} |
|
16 |
|
|
17 |
|
|
18 |
public UserConfigKey() { |
|
19 |
|
|
20 |
} |
|
21 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
import javax.persistence.*; |
|
4 |
import java.io.Serializable; |
|
5 |
|
|
6 |
/** |
|
7 |
* @Author Jiri Trefil |
|
8 |
* Join table between user and configuration |
|
9 |
* One user can have multiple (or none) configurations associated with him |
|
10 |
* One configuration can have associated multiple users |
|
11 |
* there this Many:Many relationship has to be decomposed with this table |
|
12 |
* Primary key is a Composite key (userId+configId is always a unique pair) |
|
13 |
*/ |
|
14 |
@Entity |
|
15 |
@Table(name="user_configurations") |
|
16 |
public class UserConfiguration { |
|
17 |
@EmbeddedId |
|
18 |
private UserConfigKey id; |
|
19 |
|
|
20 |
|
|
21 |
public UserConfiguration(){ |
|
22 |
} |
|
23 |
|
|
24 |
public UserConfiguration(UserConfigKey id){ |
|
25 |
this.id = id; |
|
26 |
} |
|
27 |
public UserConfigKey getUserConfigKey(){ |
|
28 |
return this.id; |
|
29 |
} |
|
30 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationRepository.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository; |
|
2 |
|
|
3 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey; |
|
4 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfiguration; |
|
5 |
import org.springframework.data.jpa.repository.JpaRepository; |
|
6 |
|
|
7 |
public interface UserConfigurationRepository extends JpaRepository<UserConfiguration, UserConfigKey> { |
|
8 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/WebSecurityConfig.java | ||
---|---|---|
74 | 74 |
.and() |
75 | 75 |
.csrf().disable() |
76 | 76 |
.authorizeRequests() |
77 |
.mvcMatchers("/v2/user/register", "/v2/user/login", "/v2/user/refresh", "/v2/user/logout").permitAll() |
|
77 |
.mvcMatchers("/v2/user/register", "/v2/user/login", "/v2/user/refresh", "/v2/user/logout","/v2/configuration//test").permitAll()
|
|
78 | 78 |
.anyRequest().authenticated() |
79 | 79 |
.and() |
80 | 80 |
.sessionManagement() |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java | ||
---|---|---|
58 | 58 |
return UserModelStatusCodes.USER_CREATION_FAILED; |
59 | 59 |
} |
60 | 60 |
|
61 |
//TODO request to OAuth for token - send user info to the oauth app for token |
|
62 | 61 |
//return okay status code, the user was created |
63 | 62 |
return UserModelStatusCodes.USER_CREATED; |
64 | 63 |
} |
Také k dispozici: Unified diff
#10517 dummy end point vytvořen. Repository napojeno a databáze pro uchování configurací vytvořena společně s Petrem Štěpánkem.