Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
curio-biblio
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thiago Anders
curio-biblio
Commits
0119f01b
Commit
0119f01b
authored
Oct 25, 2017
by
Thiago Anders
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EmprestarLivro criada e funcionando.
parent
7b8cb443
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
190 additions
and
52 deletions
+190
-52
alter1.sql
alter/alter1.sql
+61
-0
alter2.sql
alter/alter2.sql
+9
-0
alter_Cliente.oql
alter/alter_Cliente.oql
+0
-8
alter_Exemplar.oql
alter/alter_Exemplar.oql
+0
-19
alter_Livro.oql
alter/alter_Livro.oql
+0
-9
alters_Situacao.oql
alter/alters_Situacao.oql
+0
-10
HelloWorld.dpr
srv/src/HelloWorld.dpr
+9
-2
nguCliente.pas
srv/src/ngu/nguCliente.pas
+11
-1
ucuEmprestarLivro.pas
srv/src/ucu/ucuEmprestarLivro.pas
+50
-3
utuEmprestimoOQL.pas
srv/src/utu/utuEmprestimoOQL.pas
+50
-0
No files found.
alter/alter
_Emprestimo.o
ql
→
alter/alter
1.s
ql
View file @
0119f01b
-- CLASS ngSituacaoExemplar
CREATE
TABLE
SITUACAOEXEMPLAR
(
ID_SITUACAOEXEMPLAR
INT
PRIMARY
KEY
,
CODIGO
VARCHAR
(
32
)
NOT
NULL
,
DESCRICAO
VARCHAR
(
128
)
NOT
NULL
);
-- CLASS ngLivro
CREATE
TABLE
LIVRO
(
ID_LIVRO
INT
PRIMARY
KEY
,
TITULO
VARCHAR
(
200
)
NOT
NULL
,
AUTOR
VARCHAR
(
128
)
NOT
NULL
,
EDICAO
VARCHAR
(
64
)
NOT
NULL
);
-- CLASS ngCliente
CREATE
TABLE
CLIENTE
(
ID_CLIENTE
INT
PRIMARY
KEY
,
NOME
VARCHAR
(
256
)
NOT
NULL
,
CPF
VARCHAR
(
11
)
NOT
NULL
);
-- CLASS ngExemplar
CREATE
TABLE
EXEMPLAR
(
ID_EXEMPLAR
INT
PRIMARY
KEY
,
CODIGO
VARCHAR
(
32
)
NOT
NULL
,
ID_SITUACAOEXEMPLAR
INT
NOT
NULL
,
ID_LIVRO
INT
NOT
NULL
);
-- CLASS ngExemplar
-- RELATION ngSituacaoExemplar(0..*) <----> (1..1)ngExemplar
ALTER
TABLE
EXEMPLAR
ADD
CONSTRAINT
F2999ID_SITUACAOEXEMPLAR
FOREIGN
KEY
(
ID_SITUACAOEXEMPLAR
)
REFERENCES
SITUACAOEXEMPLAR
(
ID_SITUACAOEXEMPLAR
);
CREATE
INDEX
I2999ID_SITUACAOEXEMPLAR
ON
EXEMPLAR
(
ID_SITUACAOEXEMPLAR
);
-- RELATION ngLivro(0..*) <----> (1..1)ngExemplar
ALTER
TABLE
EXEMPLAR
ADD
CONSTRAINT
F2999ID_LIVRO
FOREIGN
KEY
(
ID_LIVRO
)
REFERENCES
LIVRO
(
ID_LIVRO
);
CREATE
INDEX
I2999ID_LIVRO
ON
EXEMPLAR
(
ID_LIVRO
);
-- CLASS ngEmprestimo
-- CLASS ngEmprestimo
CREATE
TABLE
EMPRESTIMO
(
CREATE
TABLE
EMPRESTIMO
(
ID_EMPRESTIMO
INT
PRIMARY
KEY
,
ID_EMPRESTIMO
INT
PRIMARY
KEY
,
...
@@ -17,5 +58,4 @@ CREATE INDEX I3000ID_EXEMPLAR ON EMPRESTIMO (ID_EXEMPLAR);
...
@@ -17,5 +58,4 @@ CREATE INDEX I3000ID_EXEMPLAR ON EMPRESTIMO (ID_EXEMPLAR);
-- RELATION ngCliente(0..*) <----> (1..1)ngEmprestimo
-- RELATION ngCliente(0..*) <----> (1..1)ngEmprestimo
ALTER
TABLE
EMPRESTIMO
ADD
CONSTRAINT
F3000ID_CLIENTE
FOREIGN
KEY
(
ID_CLIENTE
)
REFERENCES
CLIENTE
(
ID_CLIENTE
);
ALTER
TABLE
EMPRESTIMO
ADD
CONSTRAINT
F3000ID_CLIENTE
FOREIGN
KEY
(
ID_CLIENTE
)
REFERENCES
CLIENTE
(
ID_CLIENTE
);
CREATE INDEX I3000ID_CLIENTE ON EMPRESTIMO (ID_CLIENTE);
CREATE
INDEX
I3000ID_CLIENTE
ON
EMPRESTIMO
(
ID_CLIENTE
);
\ No newline at end of file
alter/alter2.sql
0 → 100644
View file @
0119f01b
INSERT
INTO
SITUACAOEXEMPLAR
VALUES
(
1
,
'1'
,
'Disponível'
)
INSERT
INTO
SITUACAOEXEMPLAR
VALUES
(
2
,
'2'
,
'Emprestado'
)
INSERT
INTO
SITUACAOEXEMPLAR
VALUES
(
3
,
'3'
,
'Reservado'
)
INSERT
INTO
SITUACAOEXEMPLAR
VALUES
(
4
,
'4'
,
'Outro'
)
INSERT
INTO
EXEMPLAR
VALUES
(
1
,
'34523452345'
,
1
,
1
)
INSERT
INTO
EXEMPLAR
VALUES
(
2
,
'34523452346'
,
1
,
1
)
INSERT
INTO
EXEMPLAR
VALUES
(
3
,
'34523452347'
,
1
,
2
)
INSERT
INTO
EXEMPLAR
VALUES
(
4
,
'34523452348'
,
1
,
2
)
alter/alter_Cliente.oql
deleted
100644 → 0
View file @
7b8cb443
-- CLASS ngCliente
CREATE TABLE CLIENTE (
ID_CLIENTE INT PRIMARY KEY,
NOME VARCHAR(256) NOT NULL,
CPF VARCHAR(11) NOT NULL
);
alter/alter_Exemplar.oql
deleted
100644 → 0
View file @
7b8cb443
-- CLASS ngExemplar
CREATE TABLE EXEMPLAR (
ID_EXEMPLAR INT PRIMARY KEY,
CODIGO VARCHAR(32) NOT NULL,
ID_SITUACAOEXEMPLAR INT NOT NULL,
ID_LIVRO INT NOT NULL
);
-- CLASS ngExemplar
-- RELATION ngSituacaoExemplar(0..*) <----> (1..1)ngExemplar
ALTER TABLE EXEMPLAR ADD CONSTRAINT F2999ID_SITUACAOEXEMPLAR FOREIGN KEY (ID_SITUACAOEXEMPLAR) REFERENCES SITUACAOEXEMPLAR(ID_SITUACAOEXEMPLAR);
CREATE INDEX I2999ID_SITUACAOEXEMPLAR ON EXEMPLAR (ID_SITUACAOEXEMPLAR);
-- RELATION ngLivro(0..*) <----> (1..1)ngExemplar
ALTER TABLE EXEMPLAR ADD CONSTRAINT F2999ID_LIVRO FOREIGN KEY (ID_LIVRO) REFERENCES LIVRO(ID_LIVRO);
CREATE INDEX I2999ID_LIVRO ON EXEMPLAR (ID_LIVRO);
alter/alter_Livro.oql
deleted
100644 → 0
View file @
7b8cb443
-- CLASS ngLivro
CREATE TABLE LIVRO (
ID_LIVRO INT PRIMARY KEY,
TITULO VARCHAR(200) NOT NULL,
AUTOR VARCHAR(128) NOT NULL,
EDICAO VARCHAR(64) NOT NULL
);
alter/alters_Situacao.oql
deleted
100644 → 0
View file @
7b8cb443
-- CLASS ngSituacaoExemplar
CREATE TABLE SITUACAOEXEMPLAR (
ID_SITUACAOEXEMPLAR INT PRIMARY KEY,
CODIGO VARCHAR(32) NOT NULL,
DESCRICAO VARCHAR(128) NOT NULL
);
srv/src/HelloWorld.dpr
View file @
0119f01b
...
@@ -89,10 +89,17 @@ uses
...
@@ -89,10 +89,17 @@ uses
ucuCadastroUsuarioSistema,
ucuCadastroUsuarioSistema,
utuSysUtils,
utuSysUtils,
acuRegisterModelMappings in 'lib\acuRegisterModelMappings.pas',
acuRegisterModelMappings in 'lib\acuRegisterModelMappings.pas',
nguVersaoBanco in 'ngu\nguVersaoBanco.pas',
ucuHelloWorldMain in 'ucu\ucuHelloWorldMain.pas',
ucuHelloWorldMain in 'ucu\ucuHelloWorldMain.pas',
svuHelloWorld in 'svuHelloWorld.pas' {svHelloWorld: TService},
svuHelloWorld in 'svuHelloWorld.pas' {svHelloWorld: TService},
ucuHelloWorld in 'ucu\ucuHelloWorld.pas';
ucuHelloWorld in 'ucu\ucuHelloWorld.pas',
ucuEmprestarLivro in 'ucu\ucuEmprestarLivro.pas',
utuEmprestimoOQL in 'utu\utuEmprestimoOQL.pas',
nguCliente in 'ngu\nguCliente.pas',
nguEmprestimo in 'ngu\nguEmprestimo.pas',
nguExemplar in 'ngu\nguExemplar.pas',
nguLivro in 'ngu\nguLivro.pas',
nguSituacaoExemplar in 'ngu\nguSituacaoExemplar.pas',
nguVersaoBanco in 'ngu\nguVersaoBanco.pas';
var
var
lErros : TStringList;
lErros : TStringList;
...
...
srv/src/ngu/nguCliente.pas
View file @
0119f01b
...
@@ -4,7 +4,7 @@ unit nguCliente;
...
@@ -4,7 +4,7 @@ unit nguCliente;
interface
interface
uses
uses
acuframework
;
acuframework
,
utuMessage
;
type
type
ngCliente
=
class
(
acPersistentObject
)
ngCliente
=
class
(
acPersistentObject
)
...
@@ -12,6 +12,8 @@ type
...
@@ -12,6 +12,8 @@ type
FNome
:
acString
;
FNome
:
acString
;
FCPF
:
acString
;
FCPF
:
acString
;
fEmprestimos
:
acRelationPartnerList
;
fEmprestimos
:
acRelationPartnerList
;
public
procedure
toXML
(
piField
:
utField
);
published
published
property
Nome
:
acString
read
FNome
write
FNome
;
property
Nome
:
acString
read
FNome
write
FNome
;
property
CPF
:
acString
read
FCPF
write
FCPF
;
property
CPF
:
acString
read
FCPF
write
FCPF
;
...
@@ -20,6 +22,14 @@ type
...
@@ -20,6 +22,14 @@ type
implementation
implementation
{ ngCliente }
procedure
ngCliente
.
toXML
(
piField
:
utField
);
begin
piField
.
AddAttribute
(
'OID'
).
AsString
:=
Self
.
IDO
.
AsString
;
piField
.
AddAttribute
(
'Nome'
).
AsString
:=
Self
.
Nome
.
AsString
;
piField
.
AddAttribute
(
'CPF'
).
AsString
:=
Self
.
CPF
.
AsString
;
end
;
initialization
initialization
...
...
srv/src/ucu/ucuEmprestarLivro.pas
View file @
0119f01b
...
@@ -25,7 +25,13 @@ type
...
@@ -25,7 +25,13 @@ type
implementation
implementation
uses
uses
ucuManager
;
ucuManager
,
utuMessage
{define utField}
,
acuFramework
,
utuEmprestimoOQL
,
acuObject
{define acEnumerator}
,
nguCliente
;
procedure
ucEmprestarLivro
.
Initialize
;
procedure
ucEmprestarLivro
.
Initialize
;
begin
begin
...
@@ -39,9 +45,50 @@ begin
...
@@ -39,9 +45,50 @@ begin
end
;
end
;
procedure
ucEmprestarLivro
.
Effect_PesquisarUsuario
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucEmprestarLivro
.
Effect_PesquisarUsuario
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
var
lFieldUsuario
,
lFieldUsuarios
:
utField
;
lOQL
:
IObterClientes
;
lListUsuarios
:
acPersistentObjectList
;
lEnumUsuario
:
acEnumerator
;
lUsuario
:
ngCliente
;
begin
begin
lFieldUsuario
:=
piRequest
.
Message
.
RootField
.
FieldByName
(
'Cliente'
);
lOQL
:=
utEmprestimoOQL
.
ObterClientes
(
Self
.
Session
);
lFieldUsuarios
:=
piRequest
.
Response
.
RootField
.
AddField
(
'Cliente'
);
lListUsuarios
:=
acPersistentObjectList
.
Create
(
ngCliente
);
try
if
lFieldUsuario
.
HasAttribute
(
'Nome'
)
then
lOQL
.
Param_nome
.
Value
:=
lFieldUsuario
.
AttributeByName
(
'Nome'
).
AsString
else
lOQL
.
Param_nome
.
SetNull
;
if
lFieldUsuario
.
HasAttribute
(
'CPF'
)
then
lOQL
.
Param_cpf
.
Value
:=
lFieldUsuario
.
AttributeByName
(
'CPF'
).
AsString
else
lOQL
.
Param_cpf
.
SetNull
;
lOQL
.
LoadList
(
lListUsuarios
);
lEnumUsuario
:=
acEnumerator
.
Create
(
lListUsuarios
);
try
while
not
lEnumUsuario
.
EOL
do
begin
lUsuario
:=
lEnumUsuario
.
Current
as
ngCliente
;
lUsuario
.
toXML
(
lFieldUsuarios
.
AddField
(
'Cliente'
));
lEnumUsuario
.
MoveNext
;
end
;
finally
lEnumUsuario
.
Free
;
end
;
finally
lListUsuarios
.
Free
;
end
;
piRequest
.
Processed
:=
True
;
piRequest
.
Processed
:=
True
;
end
;
end
;
...
...
srv/src/utu/utuEmprestimoOQL.pas
0 → 100644
View file @
0119f01b
unit
utuEmprestimoOQL
;
interface
uses
acuOQL
,
acuFramework
;
type
IObterClientes
=
interface
(
IOQLQuery
)
function
Param_nome
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
end
;
utEmprestimoOQL
=
class
class
function
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
end
;
implementation
type
TObterClientes
=
class
(
acOQLQuery
,
IObterClientes
)
function
Param_nome
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
end
;
{ TObterClientes }
function
TObterClientes
.
Param_nome
:
acOQLParamString
;
begin
result
:=
acOQLParamString
(
Self
.
ParamByName
(
'nome'
));
end
;
function
TObterClientes
.
Param_cpf
:
acOQLParamString
;
begin
result
:=
acOQLParamString
(
Self
.
ParamByName
(
'cpf'
));
end
;
{ utOQLs }
class
function
utEmprestimoOQL
.
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
begin
result
:=
TObterClientes
.
Create
(
pisessao
,
'SELECT ngCliente'
+
#
13
#
10
+
'FROM ngCliente'
+
#
13
#
10
+
'WHERE (ngCliente.Nome LIKE ''%''+?nome:acString+''%'' OR ?nome:acString IS NULL)'
+
#
13
#
10
+
' AND (ngCliente.CPF = ?cpf:acString OR ?cpf:acString IS NULL)'
);
end
;
end
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment