This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Micronaut adapter for Spring application listeners. | |
* Grails now uses micronaut so application events will be listened to here. | |
* To avoid rewriting event listening configuration, based on spring, this class dispatches events to the spring listeners. | |
*/ | |
@Singleton | |
class ApplicationEventListenerAdapter implements ApplicationEventListener<WhozEvent> { | |
@Inject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
@EnableWhozEvent([ProfilePublisher, SkillPublisher]) | |
class WhozPublisherEventConfig { | |
/** | |
* Application context from micronaut. | |
* Event listener must be registered on it as singletons, | |
* because the bean resolver of the micronaut application listener only evaluates singletons. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
ObjectId id | |
String firstName | |
String lastName | |
static constraints = { | |
firstName nullable: false, index: true | |
lastName nullable: false, index: true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company { | |
ObjectId id | |
String name | |
List<Person> employees | |
static constraints = { | |
name nullable: false, index: true | |
} | |
static hasMany = [employees: Person] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company { | |
String name | |
static constraints = { | |
name nullable: false, index: true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
ObjectId id | |
String firstName | |
String lastName | |
ObjectId companyId | |
static constraints = { | |
firstName nullable: false, index: true | |
lastName nullable: false, index: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonService { | |
public Person findByFirstName(String firstName){ | |
return Person.findByFirstName(firstName) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonService { | |
@Inject | |
PersonRepository personRepository | |
public Person findByFirstName(String firstName){ | |
return personRepository.findByFirstName(firstName) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersonGormRepositoryService implements PersonRepository { | |
@Override | |
Workspace findByFirstName(@NotNull String firstName) { | |
return Person.withStatelessSession { Person.findByFirstName(firstName) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersonController { | |
PersonService personService | |
def create(CreatePersonCommand createPersonCommand) { | |
Person personToCreate = PersonConverter.convertCreateCommandToDomain(createPersonCommand) | |
Person person = personService.create(personToCreate) | |
PersonOutput personOutput = PersonConverter.convertDomainToOutput(person) | |
render personOutput | |
} |
OlderNewer