-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shanu
committed
Dec 5, 2010
1 parent
685266c
commit c2c1322
Showing
20 changed files
with
189 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<project name="mgift" default="setupdb"> | ||
<property name="db.driver" value="org.postgresql.Driver"/> | ||
<property name="db.url" value="jdbc:postgresql://localhost:5432/GIFTDB"/> | ||
<property name="db.username" value="app_user"/> | ||
<property name="db.password" value="password"/> | ||
|
||
<path id="project.classpath"> | ||
<fileset dir="lib"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
<fileset dir="buildlib"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
</path> | ||
|
||
<macrodef name="exec_sql"> | ||
<attribute name="src"/> | ||
<attribute name="onerror"/> | ||
<sequential> | ||
<sql | ||
classpathref="project.classpath" | ||
driver="${db.driver}" | ||
url="${db.url}" | ||
userid="${db.username}" | ||
password="${db.password}" | ||
src="@{src}" | ||
onerror="@{onerror}" | ||
delimiter=";" | ||
/> | ||
</sequential> | ||
</macrodef> | ||
|
||
|
||
<taskdef name="dbdeploy" classname="com.dbdeploy.AntTarget" classpathref="project.classpath"/> | ||
|
||
<target name="drop.create.schema" | ||
description="drop the current schema and builds the baseline database"> | ||
<exec_sql src="sql/schema.sql" onerror="abort"/> | ||
</target> | ||
|
||
<target name="setupdb" depends="drop.create.schema"> | ||
<dbdeploy driver="${db.driver}" url="${db.url}" | ||
userid="app_user" | ||
password="password" | ||
dir="sql" | ||
/> | ||
</target> | ||
</project> |
Binary file not shown.
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
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
1 change: 1 addition & 0 deletions
1
...ls-app/controllers/AdminController.groovy → ...breigns/controller/AdminController.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package com.breigns.controller | ||
|
||
class AdminController{ | ||
def index = { | ||
|
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
2 changes: 2 additions & 0 deletions
2
...s-app/controllers/LogoutController.groovy → ...reigns/controller/LogoutController.groovy
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.breigns.gift | ||
|
||
class AppUser { | ||
String firstName | ||
String lastName | ||
String username | ||
String password | ||
boolean enabled | ||
boolean accountExpired | ||
boolean accountLocked | ||
boolean passwordExpired | ||
Date dateCreated | ||
Date lastUpdated | ||
|
||
static constraints = { | ||
username blank: false, unique: true | ||
password blank: false | ||
} | ||
|
||
static mapping = { | ||
password column: '`password`' | ||
} | ||
|
||
Set<Role> getAuthorities() { | ||
AppUserRole.findAllByAppUser(this).collect { it.role } as Set | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...omain/com/malabar/gift/AppUserRole.groovy → ...omain/com/breigns/gift/AppUserRole.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.malabar.gift | ||
package com.breigns.gift | ||
|
||
import org.apache.commons.lang.builder.HashCodeBuilder | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.breigns.gift | ||
|
||
class Company { | ||
String name | ||
String address | ||
Date dateCreated | ||
|
||
static hasMany = [vouchers:Voucher] | ||
} |
2 changes: 1 addition & 1 deletion
2
...s-app/domain/com/malabar/gift/Role.groovy → ...s-app/domain/com/breigns/gift/Role.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.malabar.gift | ||
package com.breigns.gift | ||
|
||
class Role { | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.breigns.gift | ||
|
||
class Voucher { | ||
Integer sequenceNumber | ||
String barcodeAlpha | ||
Double value | ||
Date dateCreated | ||
Date lastUpdated | ||
|
||
static belongsTo = Company | ||
|
||
static constraints = { | ||
barcodeAlpha(maxSize:10,minSize:10) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.breigns.service | ||
|
||
class AdminService { | ||
} |
20 changes: 20 additions & 0 deletions
20
grails-app/services/com/breigns/service/CompanyService.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.breigns.service | ||
|
||
import com.breigns.gift.Company | ||
import com.breigns.gift.Voucher | ||
import org.apache.commons.lang.RandomStringUtils | ||
|
||
class CompanyService { | ||
void createVouchers(String companyName, int sequenceStart, int sequenceEnd,double price) { | ||
def company = Company.findByName(companyName) | ||
for(int i=sequenceStart;i<=sequenceEnd;i++){ | ||
company.addToVouchers(new Voucher(sequenceNumber:i, | ||
barcodeAlpha:generateBarCodeAlpha(),value:price)) | ||
} | ||
|
||
} | ||
|
||
String generateBarCodeAlpha(){ | ||
RandomStringUtils.randomAlphabetic(10).toUpperCase() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
|
||
<%@ page contentType="text/html;charset=UTF-8" %> | ||
<html> | ||
<head><title>Simple GSP page</title></head> | ||
<body>Place your content here</body> | ||
<head><title>Admin DashBoard</title> | ||
<style type="text/css"> | ||
body { | ||
color: black; | ||
font-family: verdana, arial, sans-serif; | ||
font-size: 17px; | ||
font-weight: bold; | ||
background-color: #e4c52d; | ||
} | ||
</style> | ||
</head> | ||
<body>Place your content here</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
create table app_user (id int8 not null, version int8 not null, account_expired bool not null, account_locked bool not null, date_created timestamp not null, enabled bool not null, first_name varchar(255) not null, last_name varchar(255) not null, last_updated timestamp not null, "password" varchar(255) not null, password_expired bool not null, username varchar(255) not null unique, primary key (id)); | ||
create table app_user_role (role_id int8 not null, app_user_id int8 not null, primary key (role_id, app_user_id)); | ||
create table company (id int8 not null, version int8 not null, address varchar(255) not null, date_created timestamp not null, name varchar(255) not null, primary key (id)); | ||
create table company_voucher (company_vouchers_id int8, voucher_id int8); | ||
create table role (id int8 not null, version int8 not null, authority varchar(255) not null unique, primary key (id)); | ||
create table voucher (id int8 not null, version int8 not null, barcode_alpha varchar(10) not null, date_created timestamp not null, last_updated timestamp not null, sequence_number int4 not null, value float8 not null, primary key (id)); | ||
alter table app_user_role add constraint FK9CE8F3CC1BE77175 foreign key (role_id) references role; | ||
alter table app_user_role add constraint FK9CE8F3CCF927EE22 foreign key (app_user_id) references app_user; | ||
alter table company_voucher add constraint FKC3CDA4ECDE2BF275 foreign key (company_vouchers_id) references company; | ||
alter table company_voucher add constraint FKC3CDA4EC2BD3799F foreign key (voucher_id) references voucher; | ||
create sequence hibernate_sequence; | ||
|
||
--Data | ||
insert into role(id,version,authority) values (1,1,'ROLE_ADMIN'); | ||
insert into role(id,version,authority) values (2,1,'ROLE_DEALER'); | ||
|
||
INSERT INTO app_user(id, "version", account_expired, account_locked, date_created,enabled, first_name, last_name, last_updated, "password", password_expired,username)VALUES (1, 1, false, false, current_timestamp,true, 'Fanzeem', 'Ahmed', current_timestamp,'3723e615dd927e7534f2f4eafa71adae6df823219ee71265bae56ba5e6927f18', false,'admin'); | ||
insert into app_user_role(role_id, app_user_id )values(1,1); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
drop schema if exists public cascade; | ||
create schema public authorization app_user; | ||
CREATE TABLE changelog ( | ||
change_number BIGINT NOT NULL, | ||
complete_dt TIMESTAMP NOT NULL, | ||
applied_by text NOT NULL, | ||
description text NOT NULL | ||
); |