Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from tesler-platform/feature/apply-formatting-…
Browse files Browse the repository at this point in the history
…consistent-to-auto-imported-ide-settings

1) apply formatting consistent to auto imported ide settings
  • Loading branch information
IgorNB authored Aug 20, 2021
2 parents 3e175bc + 5b404ef commit b71df63
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 10 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<!--delete after fix https://github.com/spring-projects/spring-security/issues/9787-->
<spring-security.version>5.5.1</spring-security.version>
<spring-security-crypto.version>5.5.0</spring-security-crypto.version>
</properties>

<repositories>
Expand Down Expand Up @@ -55,6 +56,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>${spring-security-crypto.version}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/demo/conf/ApplicationConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ FreeMarkerViewResolver freemarkerViewResolver() {
resolver.setContentType("text/html;charset=UTF-8");
return resolver;
}

}
1 change: 1 addition & 0 deletions src/main/java/io/demo/conf/security/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ public KeycloakConfigResolver keycloakConfigResolver() {
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@
public class TeslerKeycloakAccount extends SimpleKeycloakAccount implements TeslerUserDetailsInterface {

private static final long serialVersionUID = 4714671346784362939L;

private Long id;

private String username;

private String password;

private LOV userRole;

private LOV timezone;

private LOV localeCd;

private Set<GrantedAuthority> authorities;

public TeslerKeycloakAccount(Principal principal, Set<String> roles, RefreshableKeycloakSecurityContext securityContext) {
public TeslerKeycloakAccount(Principal principal, Set<String> roles,
RefreshableKeycloakSecurityContext securityContext) {
super(principal, roles, securityContext);
}

Expand All @@ -46,4 +54,5 @@ public boolean isCredentialsNonExpired() {
public boolean isEnabled() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public Authentication authenticate(Authentication authentication) throws Authent
txService.invokeInTx(() -> {
upsertUserAndRoles(
account.getKeycloakSecurityContext().getToken(),
accessToken.getAccount().getRoles());
accessToken.getAccount().getRoles()
);
return null;
});

Expand Down Expand Up @@ -137,4 +138,5 @@ private void updateUser(AccessToken accessToken, String role, User user) {
user.setActive(true);
user.setDepartment(jpaDao.findById(Department.class, 0L));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public TeslerUserDetailsInterface getAuthenticationDetails(Authentication auth)
}
}

private TeslerKeycloakAccount mapTokenToTeslerDetails(KeycloakAuthenticationToken token, KeycloakAuthenticationToken accessToken, SimpleKeycloakAccount account) {
private TeslerKeycloakAccount mapTokenToTeslerDetails(KeycloakAuthenticationToken token,
KeycloakAuthenticationToken accessToken, SimpleKeycloakAccount account) {
TeslerKeycloakAccount details = new TeslerKeycloakAccount(
account.getPrincipal(),
accessToken.getAccount().getRoles(),
account.getKeycloakSecurityContext());
account.getKeycloakSecurityContext()
);

txService.invokeInTx(() -> {
User user = getUserByLogin(token.getAccount().getKeycloakSecurityContext().getToken().getName().toUpperCase());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/demo/controller/TeslerRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

@Getter
public enum TeslerRestController implements EnumBcIdentifier {

// @formatter:on
client(ClientReadResponseService.class),
contact(client, ClientContactService.class),
clientEdit(ClientWriteResponseService.class),
contactEdit(clientEdit, ClientContactService.class);
// @formatter:on

public static final EnumBcIdentifier.Holder<TeslerRestController> Holder = new Holder<>(TeslerRestController.class);

Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/demo/dto/ClientAbstractDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ public abstract class ClientAbstractDTO extends DataResponseDTO {
this.status = client.getStatus();
this.color = Optional.ofNullable(client.getImportance()).map(ClientImportance::getColor).orElse(null);
}

}
5 changes: 4 additions & 1 deletion src/main/java/io/demo/dto/ClientReadDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
public class ClientReadDTO extends ClientAbstractDTO {

private String address;

private String fieldOfActivity;

public ClientReadDTO(Client client) {
super(client);
this.address = String.join(", ",
this.address = String.join(
", ",
client.getStreet(),
client.getBuilding(),
client.getCity()
Expand All @@ -29,4 +31,5 @@ public ClientReadDTO(Client client) {
.collect(Collectors.joining(", "));

}

}
1 change: 1 addition & 0 deletions src/main/java/io/demo/dto/ContactDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public ContactDTO(Contact contact) {
this.phoneNumber = contact.getPhoneNumber();
this.email = contact.getEmail();
}

}
1 change: 1 addition & 0 deletions src/main/java/io/demo/entity/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ public class Client extends BaseEntity {

@Enumerated(value = EnumType.STRING)
private ClientStatus status;

}
1 change: 1 addition & 0 deletions src/main/java/io/demo/entity/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public class Contact extends BaseEntity {
private String phoneNumber;

private String email;

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ public void buildRowDependentMeta(RowDependentFieldsMeta<ContactDTO> fields, Inn
public void buildIndependentMeta(FieldsMeta<ContactDTO> fields, InnerBcDescription bcDescription, Long parentId) {

}

}
2 changes: 2 additions & 0 deletions src/main/java/io/demo/service/ClientContactService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
public class ClientContactService extends VersionAwareResponseService<ContactDTO, Contact> {

private final ContactRepository contactRepository;

private final ClientRepository clientRepository;

public ClientContactService(ContactRepository contactRepository, ClientRepository clientRepository) {
Expand Down Expand Up @@ -66,4 +67,5 @@ public Actions<ContactDTO> getActions() {
.save().add()
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public void buildRowDependentMeta(RowDependentFieldsMeta<ClientReadDTO> fields,
fields.setDrilldown(
ClientReadDTO_.fullName,
DrillDownType.INNER,
"/screen/client/view/clientview/" + TeslerRestController.client + "/" + id);
"/screen/client/view/clientview/" + TeslerRestController.client + "/" + id
);
}

@Override
public void buildIndependentMeta(FieldsMeta<ClientReadDTO> fields, InnerBcDescription bcDescription,
Long parentId) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ public Actions<ClientReadDTO> getActions() {
public boolean isDeferredCreationSupported(BusinessComponent bc) {
return false;
}

}
11 changes: 8 additions & 3 deletions src/main/java/io/demo/service/ClientWriteFieldMetaBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@Service
public class ClientWriteFieldMetaBuilder extends FieldMetaBuilder<ClientWriteDTO> {

@Override
public void buildRowDependentMeta(RowDependentFieldsMeta<ClientWriteDTO> fields, InnerBcDescription bcDescription,
Long id, Long parentId) {
Expand All @@ -25,15 +26,18 @@ public void buildRowDependentMeta(RowDependentFieldsMeta<ClientWriteDTO> fields,
ClientWriteDTO_.importance,
ClientWriteDTO_.fieldOfActivity
);
fields.setRequired(ClientWriteDTO_.fullName,
fields.setRequired(
ClientWriteDTO_.fullName,
ClientWriteDTO_.importance,
ClientWriteDTO_.description,
ClientWriteDTO_.city,
ClientWriteDTO_.fieldOfActivity);
ClientWriteDTO_.fieldOfActivity
);

fields.setEnumValues(ClientWriteDTO_.importance, ClientImportance.values());

fields.setDictionaryTypeWithCustomValues(ClientWriteDTO_.fieldOfActivity,
fields.setDictionaryTypeWithCustomValues(
ClientWriteDTO_.fieldOfActivity,
Arrays.stream(FieldOfActivity.values()).map(FieldOfActivity::getValue)
.toArray(String[]::new)
);
Expand All @@ -44,4 +48,5 @@ public void buildIndependentMeta(FieldsMeta<ClientWriteDTO> fields, InnerBcDescr
Long parentId) {

}

}

0 comments on commit b71df63

Please sign in to comment.