Skip to content

Commit 87f82ce

Browse files
authored
Merge pull request #2129 from objectcomputing/feature-2106/add-category-to-skills
Feature 2106/add category to skills
2 parents f24d263 + f59e11c commit 87f82ce

File tree

62 files changed

+213728
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+213728
-37
lines changed

server/src/main/java/com/objectcomputing/checkins/exceptions/handlers/AlreadyExistsHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@Produces
1616
@Singleton
1717
@Requires(classes = {AlreadyExistsException.class, ExceptionHandler.class})
18-
public class AlreadyExistsHandler implements ExceptionHandler<AlreadyExistsException, HttpResponse> {
18+
public class AlreadyExistsHandler implements ExceptionHandler<AlreadyExistsException, HttpResponse<?>> {
1919

2020
@Override
2121
public HttpResponse<?> handle(HttpRequest request, AlreadyExistsException e) {

server/src/main/java/com/objectcomputing/checkins/exceptions/handlers/ArgumentsHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@Produces
1515
@Singleton
1616
@Requires(classes = {BadArgException.class, ExceptionHandler.class})
17-
public class ArgumentsHandler implements ExceptionHandler<BadArgException, HttpResponse> {
17+
public class ArgumentsHandler implements ExceptionHandler<BadArgException, HttpResponse<?>> {
1818

1919
@Override
2020
public HttpResponse<?> handle(HttpRequest request, BadArgException e) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.objectcomputing.checkins.exceptions.handlers;
2+
3+
import io.micronaut.context.annotation.Requires;
4+
import io.micronaut.data.exceptions.DataAccessException;
5+
import io.micronaut.http.HttpRequest;
6+
import io.micronaut.http.HttpResponse;
7+
import io.micronaut.http.HttpStatus;
8+
import io.micronaut.http.annotation.Produces;
9+
import io.micronaut.http.hateoas.JsonError;
10+
import io.micronaut.http.hateoas.Link;
11+
import io.micronaut.http.server.exceptions.ExceptionHandler;
12+
import jakarta.inject.Singleton;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
16+
@Produces
17+
@Singleton
18+
@Requires(classes = {DataAccessException.class, ExceptionHandler.class})
19+
public class DataAccessExceptionHandler implements ExceptionHandler<DataAccessException, HttpResponse<?>> {
20+
21+
private static final Logger LOG = LoggerFactory.getLogger(DataAccessExceptionHandler.class);
22+
@Override
23+
public HttpResponse<?> handle(HttpRequest request, DataAccessException e) {
24+
JsonError error = new JsonError(e.getMessage())
25+
.link(Link.SELF, Link.of(request.getUri()));
26+
LOG.error(e.getMessage());
27+
return HttpResponse.<JsonError>status(HttpStatus.BAD_REQUEST).body(error);
28+
}
29+
30+
}

server/src/main/java/com/objectcomputing/checkins/exceptions/handlers/NotFoundHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@Produces
1515
@Singleton
1616
@Requires(classes = {NotFoundException.class, ExceptionHandler.class})
17-
public class NotFoundHandler implements ExceptionHandler<NotFoundException, HttpResponse> {
17+
public class NotFoundHandler implements ExceptionHandler<NotFoundException, HttpResponse<?>> {
1818

1919
@Override
2020
public HttpResponse<?> handle(HttpRequest request, NotFoundException e) {

server/src/main/java/com/objectcomputing/checkins/exceptions/handlers/PermissionsHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@Produces
1616
@Singleton
1717
@Requires(classes = {PermissionException.class, ExceptionHandler.class})
18-
public class PermissionsHandler implements ExceptionHandler<PermissionException, HttpResponse> {
18+
public class PermissionsHandler implements ExceptionHandler<PermissionException, HttpResponse<?>> {
1919

2020
@Override
2121
public HttpResponse<?> handle(HttpRequest request, PermissionException e) {

server/src/main/java/com/objectcomputing/checkins/security/permissions/Permissions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public enum Permissions {
1717
CAN_VIEW_PROFILE_REPORT("View profile report", "Reporting"),
1818
CAN_CREATE_CHECKINS("Create check-ins", "Check-ins"),
1919
CAN_VIEW_CHECKINS("View check-ins", "Check-ins"),
20-
CAN_UPDATE_CHECKINS("Update check-ins", "Check-ins");
20+
CAN_UPDATE_CHECKINS("Update check-ins", "Check-ins"),
21+
CAN_EDIT_SKILL_CATEGORIES("Edit skill categories", "Skills"),
22+
CAN_VIEW_SKILL_CATEGORIES("View skill categories", "Skills");
2123

2224
private final String description;
2325
private final String category;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.objectcomputing.checkins.services.skill_record;
2+
3+
import com.objectcomputing.checkins.services.skillcategory.skillcategory_skill.SkillCategorySkillId;
4+
import io.micronaut.core.annotation.Introspected;
5+
import io.micronaut.data.annotation.MappedEntity;
6+
7+
import javax.persistence.Column;
8+
import javax.persistence.EmbeddedId;
9+
import javax.persistence.Table;
10+
11+
@MappedEntity
12+
@Introspected
13+
@Table(name = "skill_record")
14+
@SuppressWarnings("unused")
15+
public class SkillRecord {
16+
17+
@EmbeddedId
18+
private SkillCategorySkillId skillCategorySkillId;
19+
20+
@Column(name = "name")
21+
private String name;
22+
23+
@Column(name = "description")
24+
private String description;
25+
26+
@Column(name = "extraneous")
27+
private boolean extraneous;
28+
29+
@Column(name = "pending")
30+
private boolean pending;
31+
32+
@Column(name = "category_name")
33+
private String categoryName;
34+
35+
public SkillRecord() {}
36+
37+
public SkillCategorySkillId getSkillCategorySkillId() {
38+
return skillCategorySkillId;
39+
}
40+
41+
public void setSkillCategorySkillId(SkillCategorySkillId skillCategorySkillId) {
42+
this.skillCategorySkillId = skillCategorySkillId;
43+
}
44+
45+
public String getName() {
46+
return name;
47+
}
48+
49+
public void setName(String name) {
50+
this.name = name;
51+
}
52+
53+
public String getDescription() {
54+
return description;
55+
}
56+
57+
public void setDescription(String description) {
58+
this.description = description;
59+
}
60+
61+
public boolean isExtraneous() {
62+
return extraneous;
63+
}
64+
65+
public void setExtraneous(boolean extraneous) {
66+
this.extraneous = extraneous;
67+
}
68+
69+
public boolean isPending() {
70+
return pending;
71+
}
72+
73+
public void setPending(boolean pending) {
74+
this.pending = pending;
75+
}
76+
77+
public String getCategoryName() {
78+
return categoryName;
79+
}
80+
81+
public void setCategoryName(String categoryName) {
82+
this.categoryName = categoryName;
83+
}
84+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.objectcomputing.checkins.services.skill_record;
2+
3+
import com.objectcomputing.checkins.security.permissions.Permissions;
4+
import com.objectcomputing.checkins.services.permissions.RequiredPermission;
5+
import io.micronaut.http.HttpResponse;
6+
import io.micronaut.http.MediaType;
7+
import io.micronaut.http.MutableHttpResponse;
8+
import io.micronaut.http.annotation.Controller;
9+
import io.micronaut.http.annotation.Get;
10+
import io.micronaut.scheduling.TaskExecutors;
11+
import io.micronaut.security.annotation.Secured;
12+
import io.micronaut.security.rules.SecurityRule;
13+
import jakarta.inject.Named;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
import reactor.core.publisher.Mono;
17+
import reactor.core.scheduler.Scheduler;
18+
import reactor.core.scheduler.Schedulers;
19+
20+
import java.io.File;
21+
import java.util.concurrent.ExecutorService;
22+
23+
@Controller("/services/skills/records")
24+
@Secured(SecurityRule.IS_AUTHENTICATED)
25+
public class SkillRecordController {
26+
27+
private static final Logger LOG = LoggerFactory.getLogger(SkillRecordController.class);
28+
private final SkillRecordServices skillRecordServices;
29+
private final Scheduler ioScheduler;
30+
31+
public SkillRecordController(
32+
SkillRecordServices skillRecordServices,
33+
@Named(TaskExecutors.IO) ExecutorService ioExecutorService) {
34+
this.skillRecordServices = skillRecordServices;
35+
this.ioScheduler = Schedulers.fromExecutor(ioExecutorService);
36+
}
37+
38+
@RequiredPermission(Permissions.CAN_VIEW_SKILL_CATEGORIES)
39+
@Get(value = "/csv", produces = MediaType.TEXT_CSV)
40+
public Mono<MutableHttpResponse<File>> generateCsv() {
41+
return Mono.defer(() -> Mono.just(skillRecordServices.generateFile()))
42+
.subscribeOn(ioScheduler)
43+
.map(file -> HttpResponse
44+
.ok(file)
45+
.header("Content-Disposition", String.format("attachment; filename=%s", file.getName())))
46+
.onErrorResume(error -> {
47+
LOG.error("Something went terribly wrong during export... ", error);
48+
return Mono.just(HttpResponse.serverError());
49+
});
50+
}
51+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.objectcomputing.checkins.services.skill_record;
2+
3+
import com.objectcomputing.checkins.services.skillcategory.skillcategory_skill.SkillCategorySkillId;
4+
import io.micronaut.core.annotation.NonNull;
5+
import io.micronaut.data.jdbc.annotation.JdbcRepository;
6+
import io.micronaut.data.model.query.builder.sql.Dialect;
7+
import io.micronaut.data.repository.CrudRepository;
8+
9+
import java.util.List;
10+
11+
@JdbcRepository(dialect = Dialect.POSTGRES)
12+
public interface SkillRecordRepository extends CrudRepository<SkillRecord, SkillCategorySkillId> {
13+
14+
@NonNull
15+
List<SkillRecord> findAll();
16+
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.objectcomputing.checkins.services.skill_record;
2+
3+
import java.io.File;
4+
5+
public interface SkillRecordServices {
6+
7+
File generateFile();
8+
9+
}

0 commit comments

Comments
 (0)