Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/fta fmea UI 294 cant create syste with keycloak auth #100

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ontology-generator/ontology/fta-fmea-model.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ fta-fmea:severity rdf:type owl:DatatypeProperty ;
rdfs:label "severity" .


### http://onto.fel.cvut.cz/ontologies/fta-fmea-application/username
fta-fmea:username rdf:type owl:DatatypeProperty ;
### http://xmlns.com/foaf/0.1/accountName
foaf:accountName rdf:type owl:DatatypeProperty ;
rdfs:domain foaf:Person ;
rdfs:range xsd:string ;
rdfs:label "username" .
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/cz/cvut/kbss/analysis/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public Optional<User> findByUsername(String username) {
try {
return Optional
.of(em
.createNativeQuery("SELECT ?x WHERE { ?x a ?type ; ?hasUsername ?username . }",
.createNativeQuery("""
SELECT ?x WHERE {
?x a ?type ; ?hasUsername ?val .
FILTER(str(?val) = ?username)
}
""",
type)
.setParameter("type", typeUri)
.setParameter("hasUsername", URI.create(Vocabulary.s_p_username))
.setParameter("username", username, config.getLanguage())
.setParameter("hasUsername", URI.create(Vocabulary.s_p_accountName))
.setParameter("username", username)
.getSingleResult());
} catch (NoResultException e) {
return Optional.empty();
Expand All @@ -54,7 +59,7 @@ public String findUsername(URI uri){
String.class)
.setParameter("type", typeUri)
.setParameter("x", uri)
.setParameter("hasUsername", URI.create(Vocabulary.s_p_username))
.setParameter("hasUsername", URI.create(Vocabulary.s_p_accountName))
.getSingleResult();
} catch (NoResultException e) {
return null;
Expand All @@ -72,10 +77,15 @@ public String findUsername(URI uri){
public boolean existsWithUsername(String username) {
Objects.requireNonNull(username);
return em
.createNativeQuery("ASK WHERE { ?x a ?type ; ?hasUsername ?username . }", Boolean.class)
.createNativeQuery("""
ASK WHERE {
?x a ?type ; ?hasUsername ?val .
FILTER(str(?val) = ?username)
}
""", Boolean.class)
.setParameter("type", typeUri)
.setParameter("hasUsername", URI.create(Vocabulary.s_p_username))
.setParameter("username", username, config.getLanguage())
.setParameter("hasUsername", URI.create(Vocabulary.s_p_accountName))
.setParameter("username", username)
.getSingleResult();
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/cz/cvut/kbss/analysis/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ public class User extends AbstractEntity implements UserDetails {

@NotEmpty(message = "Username must not be empty")
@ParticipationConstraints(nonEmpty = true)
@OWLDataProperty(iri = Vocabulary.s_p_username, simpleLiteral = true)
@OWLDataProperty(iri = Vocabulary.s_p_accountName, simpleLiteral = true)
private String username;

@NotEmpty(message = "Password must not be empty")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@ParticipationConstraints(nonEmpty = true)
@OWLDataProperty(iri = Vocabulary.s_p_password, simpleLiteral = true)
private String password;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public UserReference(User u) {


@Transient
@OWLDataProperty(iri = Vocabulary.s_p_username, fetch = FetchType.EAGER )
@OWLDataProperty(iri = Vocabulary.s_p_accountName, fetch = FetchType.EAGER )
private String username;

}
Loading