Categorized into 2 types visualize the patterns using R Studio with detailed illustration from bivariate to univariate analysis using methods like boxplot, skewness, outliers, hist, par and much more
Categorized into 2 types visualize the patterns using R Studio with detailed illustration from bivariate to univariate analysis using methods like boxplot, skewness, outliers, hist, par and much more
Desk reference for data wrangling, analysis, visualization, and programming in Stata. Co-authored with Tim Essam(@StataRGIS, linkedin.com/in/timessam). See all cheat sheets at http://bit.ly/statacheatsheets. Updated 2016/06/03
Details introduction of the SQL Queries & basics of SQL queries like creating table, inserting values, updating values are discussed in this presentation.
Desk reference for data wrangling, analysis, visualization, and programming in Stata. Co-authored with Tim Essam(@StataRGIS, linkedin.com/in/timessam). See all cheat sheets at http://bit.ly/statacheatsheets. Updated 2016/06/03
Details introduction of the SQL Queries & basics of SQL queries like creating table, inserting values, updating values are discussed in this presentation.
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
Creat Shape classes from scratch DETAILS You will create 3 shape classes (Circle, Rectangle,
Triangle) that all inherit from a single abstract class called AbstractShape which implements
Shape (also created by you). You are also responsible for creating the driver class
\"Assignment7.java\" (program that tests your classes and described on page 3) which does the
following reads input data from a file instantiates various objects of the three shapes based on the
input data stores each in a LinkedList outputs this list to an output file sorts a \"copy\" of this
LinkedList of objects outputs the sorted version of the list to the output file outputs the original
list to the output file This driver program also needs to \"ignore errors in the input file that breach
the specified input format as described in the Assianment7,java details (see page 3 1. Shape.java
This is an interface that has 2 abstract methods, and passes the responsibility of implementing the
compareTo method to the class that implements Shape (you may note, nomally Comparable is
\"implemented\" by a class. However, an interface cannot implement because interfaces can only
contain abstract methods. That said, an interface can only extend other interfaces and the
responsibility of actually \"implementing\" the abstract method(s) of the super class interface is
passed on to the sub-classes) public interface Shape extends Comparable public double
calculateAreal) Il This abstract method is implemented at the concrete level public Shape
copyShape); Il also implemented at the concrete level 2. AbstractShape.java public abstract class
AbstractShape implements Shape This class should contain an instance field to store the name of
each obiect. The constructor which sets this field should receive the name and a number to be
concatenated to the name and then stored in the name field Recall, when the super class has a
parameterized constructor, the sub-classes will need to call it AND the sub- classes will need to
also provide a constructor without parameters This abstract class will implement the compareTo
method passed on from the Shape interface and will pass on the responsibility of implementing
calculateArea to the extending sub-classes (compare To will use the calculateArea method when
comparing 2 Shape objects). Along with compare To, one more concrete method should be
included. The following will be used by the sub-classes\' toString method: public String
getName) II Simply returns the name field data
Solution
in7.txt
4.4
2.5 3
8.1 3.0 5.0
2.5 3 4
2.5
tuesday
-7
1.0
3 three
3 -9
3 5
1.0
Assignment7.java
import java.io.*;
import java.util.*;
public class Assignment7 {
/**
* This is the test driver class that will include main.
* This program MUST read a file named in7.txt and
* generate an output file named out7.txt. The in7.txt
* file must be created by you based on formatting
* described shortly.
*
* @param theArgs
*/
public static void main(String[] theArgs) {
List myList = new Arra.
Should be in JavaInterface Worker should extend Serializable from .pdffashionscollect
Should be in Java
Interface Worker should extend Serializable from java.io.*
In addition to shown data fields, each Worker object should have a name field, a workerID field,
and a Department field.The classes and/or interfaces where these fields belong are not indicated,
so you need to decide where they best belong in order to reduce code redundancy as much as
possible; it may not be possible to put them in only one place.
Write get and set methods for every data field. You may use the automatic generator of your
IDE, but all data should be validated. I should not be able to set invalid data such a negative
hours. The program should not terminate when receiving bad data but should recover, whether
input is coming from a file or interactively.
All appropriate classes must override the equals method so that it compares workers by
workerID; two workers should be considered equal if they have the same workerID, even if they
are not the same kind of Worker; when comparing a WorkerObject to an object of another type,
the equals method should return false.
Class HourlyWorker should be an abstract class because it contains an abstract toString method
that will be implemented in the subclasses; in the subclasses, it should return the type of subclass
along with all data field values in a user-friendly understandable format.
Data field hours in the HourlyWorker class represents the number of hours worked so far during
the current month
Decide if any of the methods requires a precondition; if so, they should throw an appropriate
exception when the precondition is not met
Supply appropriate constructors for all concrete and abstract classes. Each should have a no-arg
constructor and a fully qualified constructor.
Create an application class named WorkerTest to demonstrate the hierarchy.
The application should create Volunteer, HourlyEmployee, and SalariedEmployee objects with
initial field values specified interactively. Invalid data should produce a message and a re-
prompt.
The application should then create a series of objects by reading initial field values from a file.
The file format is up to you. The input should test both the no-arg constructors and the fully
qualified constructors. If the file contains invalid data, the program send a message to err.out,
ignore the invalid data and proceed to the next valid data. The file input data should test all
caught exceptions. I should not be able to crash your program, regardless of the input data I
provide.
Check each object against abstract class HourlyWorker and each interface by using the
instanceof operator. Output results indicating whether each object is or is not of the checked
type.
Create an ArrayList containing the objects and polymorphically traverse the array, writing the
output of each objects\' toString() method to a file.
I know I need to do a department class and also an employee class.
Here is the code i have so far.
public abstract class Worker
{
private final String lastName;
private .
Applying Real-time SQL Changes in your Hazelcast Data GridHazelcast
In this webinar
When you have an existing relational database that you want to scale out in a Hazelcast grid and third party applications are making changes to the underlying database, you get into a state where Hazelcast is unaware of these changes and will have stale data. Speedment solves this problem by tracking the database and pushing any changes into the Hazelcast grid automatically and continuously. The model supports transaction safe updates. Speedment is able to track the relational database regardless of how it is updated: using third party applications of any kind, SQL commands or even stored procedures.
This webinar aims to give you an overview on how changes to an existing SQL database can be propagated to objects in the Hazelcast grid. We will demonstrate how easy you could get a really strong database synchronisation with continuous updates of Hazelcast data-maps in glorious real-time
We’ll cover these topics:
- How to install Speedment Reflector on a relational database
- How Speedment Reflector can be integrated with Hazelcast
- Live Q&A
Presenter:
Per-Åke Minborg, CTO at Speedment
Per-Åke Minborg is founder and CTO at Speedment AB. He is a passionate Java developer, dedicated to OpenSource software and an expert in finding new ways of solving problems – the harder problem the better. As a result, he has 15+ US patent applications and invention disclosures. He has a deep understanding of in-memory databases, high-performance solutions, cloud technologies and concurrent programming. He has previously served as CTO and founder of Chilirec and the Phone Pages. Per-Åke has a M.Sc. in Electrical Engineering from Chalmers University of Technology and several years of studies in computer science and computer security at university and PhD level.
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
For the questions below, use the W3Schools customer orders database. You need to submit
thoroughly tested SQL statements. For your convenience and reference, relevant data model is
attached as a PDF document with the assignment in the Blackboard. Name of this document is
\"Relationship diagram for W3schools order pdf.\" 1) Write a query to show Customers\' Country
wise sales totals. Your query should show Customers\' Country name and the total sale value for
that Country 2) Write a query to show Product wise sales totals. Your query should Product
name and the total sale value for that Product. 3) Write a query to show the number of orders for
each shipper. Your query should show shipper name and the count of orders with the shipper. 4)
Write a query to show number of products in each product category. Your query should show
Category name and number of products in that category 5) Write a query that shows Customers\'
country wise customer count, and order count. Your query should show country name, total
number of customers from that country, and total number of orders from the customers of that
country 6) Write a query that shows the number of products supplied by each Supplier. Your
query should show Country name, supplier name and the count of products supplied by that
supplier. Note: Sale Price Orderdetails.Quantity Products.price (see an example in the class
slides deck) W3SCHOOLS SQL is located at http://www.w3schools.com/sql/default.asp
(Preferred browser is Chrome). On this page you will find a button called \"Try it yourself\".
Click on that button. You will be redirected to a page where you see a list of tables on the right
side of the page. It is highly recommended to click \'Restore Database\' button on this page
during every session. The page contains a box where you can type in an SQL statement
involving the listed tables. You type in your SQL statement in that box and click on \"Run
SQL\'\' button. The results will be displayed if your SQL statement is syntactically correct.
Solution
1. SELECT Customers.Country, SUM(OrderDetails.Quantity * Products.Price) AS Total_Sale
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID
LEFT JOIN OrderDetails ON Orders.OrderId=OrderDetails.OrderId
LEFT JOIN Products ON OrderDetails.ProductId=Products.ProductId
Group BY Customers.Country;
2. SELECT Products.ProductName, SUM(OrderDetails.Quantity * Products.Price) AS
Total_Sale FROM Customers
LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID
LEFT JOIN OrderDetails ON Orders.OrderId=OrderDetails.OrderId
LEFT JOIN Products ON OrderDetails.ProductId=Products.ProductId
Group BY Products.ProductName;
You can edit these query to get other results set..
Alexa is Amazon’s cloud-based voice service.
It is a way to communicate the system using our voice.
Alexa provides a set of built-in capabilities, referred to as skills.
Apache Commons is an Apache project focused on all aspects of reusable Java components.
It is divided into three components: Commons Proper, Commons Sandbox, Commons Dormant.
Running queries across multiple tables. This will involve the concept of joins—that is, how we join tables together.
Using joins to run queries over multiple tables, including:
Natural, inner, and cross joins
Straight joins
Left and right joins
Writing subqueries
Using SELECT statement options
Swagger is an open source software framework backed by
a large ecosystem of tools that helps developers
design, build, document and consume RESTful Web
services.
The theory of SOLID principles was
introduced by Robert C. Martin in his 2000
paper “Design Principles and Design
Patterns”.
SOLID => Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
ArangoDB is a native multi-model database system developed by triAGENS GmbH. The database system supports three important data models (key/value, documents, graphs) with one database core and a unified query language AQL (ArangoDB Query Language). ArangoDB is a NoSQL database system but AQL is similar in many ways to SQL
Geth is widely used to interact with Ethereum networks. Ethereum software enables a user to set up a
“private” or “testnet” Ethereum chain. This chain will be totally different from main chain.
Component that tell geth that we want to use/create a private Ethereum Chain:
1. Custom Genesis file
2. Custom Data Directory
3. Custom Network Id
4. Disable Node Discovery
Ethereum is an open software platform based on blockchain technology that enables developers to
build and deploy decentralized applications.
Ethereum is a distributed public blockchain network.
While the Bitcoin blockchain is used to track ownership of digital currency (bitcoins), the Ethereum
blockchain focuses on running the programming code of any decentralized application.
Ether is a cryptocurrency whose blockchain is generated by the Ethereum platform. Ether can be
transferred between accounts and used to compensate participant mining nodes for computations
performed.
Google Authenticator is a software token that implements two-step verification services using the Time-based One-time Password Algorithm (TOTP) and HMAC-based One-time Password Algorithm (HOTP), for authenticating users of mobile applications by Google. The service implements algorithms specified in RFC 6238 and RFC 4226, respectively.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
2. Topics
● Events and Auto Timestamping
● Custom ORM mapping
● Default Sort Order
● Validations and Constraints
3. Events and Auto Timestamping
GORM supports the registration of events as methods that get fired when certain events occurs such as
deletes, inserts and updates. The following is a list of supported events:
● beforeInsert - Executed before an object is initially persisted to the database. If you return false, the insert
will be cancelled.
● beforeUpdate - Executed before an object is updated. If you return false, the update will be cancelled.
● beforeDelete - Executed before an object is deleted. If you return false, the delete will be cancelled.
● beforeValidate - Executed before an object is validated
● afterInsert - Executed after an object is persisted to the database
● afterUpdate - Executed after an object has been updated
● afterDelete - Executed after an object has been deleted
● onLoad - Executed when an object is loaded from the database
To add an event simply register the relevant method with your domain class.
4. Example - The beforeInsert event
Fired before an object is saved to the database
class Person {
private static final Date NULL_DATE = new Date(0)
String firstName
String lastName
Date signupDate = NULL_DATE
def beforeInsert() {
if (signupDate == NULL_DATE) {
signupDate = new Date()
}
}
}
5. Automatic timestamping
If you define a dateCreated property it will be set to the current date for you when you create new instances.
Likewise, if you define a lastUpdated property it will be automatically be updated for you when you change
persistent instances.
class Person {
Date dateCreated
Date lastUpdated
}
6. Custom ORM mapping
Custom mappings are defined using a static mapping block defined within your domain class:
class Person {
…
static mapping = {
version false
autoTimestamp false
}
}
You can also configure global mappings in application.groovy (or an external config file) using this setting:
grails.gorm.default.mapping = {
version false
autoTimestamp false
}
7. Table and Column Names
Table names
The database table name which the class maps to can be customized using the table method:
class Person {
...
static mapping = {
table 'people'
}
}
In this case the class would be mapped to a table called people instead of the default name of person.
8. Column names
It is also possible to customize the mapping for individual columns onto the database. For example to change
the name you can do:
class Person {
String firstName
static mapping = {
table 'people'
firstName column: 'First_Name'
}
}
Here firstName is a dynamic method within the mapping Closure that has a single Map parameter. Since its
name corresponds to a domain class persistent field, the parameter values (in this case just "column") are used
to configure the mapping for that property.
9. Column type
GORM supports configuration of Hibernate types with the DSL using the type attribute. This includes specifying
user types that implement the Hibernate org.hibernate.usertype.UserType interface, which allows complete
customization of how a type is persisted.
class Address {
String number
String postCode
static mapping = {
postCode type: 'text'
}
}
10. Many-to-One/One-to-One Mappings
In the case of associations it is also possible to configure the foreign keys used to map associations. In the
case of a many-to-one or one-to-one association this is exactly the same as any regular column. For example
consider the following:
class Person {
String firstName
Address address
static mapping = {
table 'people'
firstName column: 'First_Name'
address column: 'Person_Address_Id'
}
}
11. One-to-Many Mapping
class Person {
static hasMany = [addresses: Address]
static mapping = {
addresses column: 'Person_Address_Id'
}
}
If you don’t want the column to be in the address table, but instead some intermediate join table you can use
the joinTable parameter:
class Person {
static hasMany = [addresses: Address]
static mapping = {
addresses joinTable: [name: 'Person_Addresses',
key: 'Person_Id',
column: 'Address_Id']
}
}
12. Many-to-Many Mapping
GORM, by default maps a many-to-many association using a join table.To change the column names you can
specify a column within the mappings for each class.
class Group {
...
static hasMany = [people: Person]
static mapping = {
people column: 'Group_Person_Id'
}
}
class Person {
...
static belongsTo = Group
static hasMany = [groups: Group]
static mapping = {
groups column: 'Group_Group_Id'
}
13. Many-to-Many Mapping
You can also specify the name of the join table to use:
class Group {
...
static mapping = {
people column: 'Group_Person_Id',
joinTable: 'PERSON_GROUP_ASSOCIATIONS'
}
}
class Person {
...
static mapping = {
groups column: 'Group_Group_Id',
joinTable: 'PERSON_GROUP_ASSOCIATIONS'
}
}
14. Default Sort Order
You can sort objects using query arguments such as those found in the list method:
def airports = Airport.list(sort:'name')
class Airport {
...
static mapping = {
sort "name"
}
}
class Airport {
...
static mapping = {
sort name: "desc"
}
}
15. Finally, you can configure sorting at the association level:
class Airport {
...
static hasMany = [flights: Flight]
static mapping = {
flights sort: 'number', order: 'desc'
}
}
In this case, the flights collection will always be sorted in descending order of flight number.
16. Grails allows you to apply constraints to a domain class that can then be used to validate a domain class
instance.
Constraints are applied using a "constraints" closure.
To validate a domain class you can call the "validate()" method on an instance.
class User {
String login
String password
String email
Date age
static constraints={
login(size:5..15,blank:false,unique:true)
password(size:5..15,blank:false)
email(email:true,blank:false)
age(min:new Date(),nullable:false)
}
}
Validations
17. Validating Constraints
def user = new User(params)
if(user.validate()){
//do something
} else {
user.errors.allErrors.each{
Println it
}
}
18. Custom Validators
class Response {
Survey survey
Answer answer
static constraints = {
survey blank: false
answer blank: false, validator: { val, Response obj -> val in obj.survey.answers }
}
}
The obj argument to the custom validator is the domain instance that is being validated, so we can access its
survey property and return a boolean to indicate whether the new value for the answer property, val, is valid.