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
0a47ab0c
Commit
0a47ab0c
authored
Oct 31, 2017
by
Thiago Anders
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incluir e editar livro prontos
parent
8ec60964
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
191 additions
and
21 deletions
+191
-21
EmprestimoOQL.cxoql
mdl/EmprestimoOQL.cxoql
+13
-4
HelloWorld.identcache
srv/src/HelloWorld.identcache
+0
-0
acuRegisterModelMappings.pas
srv/src/lib/acuRegisterModelMappings.pas
+43
-1
ucuCadastrarLivro.pas
srv/src/ucu/ucuCadastrarLivro.pas
+84
-16
utuEmprestimoOQL.pas
srv/src/utu/utuEmprestimoOQL.pas
+51
-0
No files found.
mdl/EmprestimoOQL.cxoql
View file @
0a47ab0c
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<DATA>
<DATA>
<oql
name=
"ContarEmprestimos
DeUmLivro"
oqltype=
"0
"
>
<oql
name=
"ContarEmprestimos
Exemplar"
oqltype=
"1
"
>
<description></description>
<description></description>
<query>
<![CDATA[SELECT count(*) as qnt
<query>
<![CDATA[SELECT count(*) as qnt
FROM ngExemplar
FROM ngExemplar,
]]>
</query>
ngExemplar.Emprestimos
WHERE ngExemplar.OID = ?oid:acInt]]>
</query>
</oql>
<oql
name=
"ContarEmprestimosLivro"
oqltype=
"1"
>
<description></description>
<query>
<![CDATA[SELECT count(*) as qnt
FROM ngLivro,
ngLivro.Exemplares,
ngLivro.Exemplares.Emprestimos
WHERE ngLivro.OID = ?oid:acInt]]>
</query>
</oql>
</oql>
<oql
name=
"ObterClientes"
oqltype=
"0"
>
<oql
name=
"ObterClientes"
oqltype=
"0"
>
<description></description>
<description></description>
...
@@ -29,7 +38,7 @@ WHERE (ngExemplar.Livro.Titulo LIKE '%'+?titulo:acString+'%' OR ?titulo:acString
...
@@ -29,7 +38,7 @@ WHERE (ngExemplar.Livro.Titulo LIKE '%'+?titulo:acString+'%' OR ?titulo:acString
ORDER BY ngExemplar.Livro.OID]]>
</query>
ORDER BY ngExemplar.Livro.OID]]>
</query>
</oql>
</oql>
<oql
name=
"ObterLivros"
oqltype=
"0"
>
<oql
name=
"ObterLivros"
oqltype=
"0"
>
<description>
Obt
m livros por t
tulo ou autor.
</description>
<description>
Obt
�m livros por t�
tulo ou autor.
</description>
<query>
<![CDATA[SELECT ngLivro
<query>
<![CDATA[SELECT ngLivro
FROM ngLivro
FROM ngLivro
WHERE (ngLivro.Titulo LIKE '%'+?titulo:acString+'%' OR ?titulo:acString IS NULL)
WHERE (ngLivro.Titulo LIKE '%'+?titulo:acString+'%' OR ?titulo:acString IS NULL)
...
...
srv/src/HelloWorld.identcache
View file @
0a47ab0c
No preview for this file type
srv/src/lib/acuRegisterModelMappings.pas
View file @
0a47ab0c
...
@@ -2020,7 +2020,7 @@ begin
...
@@ -2020,7 +2020,7 @@ begin
Result
:=
'<?xml version="1.0"?>'
+
#
13
#
10
+
Result
:=
'<?xml version="1.0"?>'
+
#
13
#
10
+
'<!--Created with Liquid XML Studio 6.1.18.0 - FREE Community Edition (http://www.liquid-technologies.com)-->'
+
#
13
#
10
+
'<!--Created with Liquid XML Studio 6.1.18.0 - FREE Community Edition (http://www.liquid-technologies.com)-->'
+
#
13
#
10
+
'<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">'
+
#
13
#
10
+
'<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">'
+
#
13
#
10
+
' <xs:element name="SYSM
A
G">'
+
#
13
#
10
+
' <xs:element name="SYSM
S
G">'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:sequence minOccurs="1" maxOccurs="1">'
+
#
13
#
10
+
' <xs:sequence minOccurs="1" maxOccurs="1">'
+
#
13
#
10
+
' <xs:element name="Livro">'
+
#
13
#
10
+
' <xs:element name="Livro">'
+
#
13
#
10
+
...
@@ -2077,6 +2077,47 @@ begin
...
@@ -2077,6 +2077,47 @@ begin
''
;
''
;
end
;
end
;
function
GetXSDOut_3227_smucCadastrarLivro_EditandoCadastro_RM_CONCLUIR_EDICAO
:
String
;
begin
Result
:=
'<?xml version="1.0"?>'
+
#
13
#
10
+
'<!--Created with Liquid XML Studio 6.1.18.0 - FREE Community Edition (http://www.liquid-technologies.com)-->'
+
#
13
#
10
+
'<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">'
+
#
13
#
10
+
' <xs:element name="SYSMSG">'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:sequence minOccurs="1" maxOccurs="1">'
+
#
13
#
10
+
' <xs:element name="Livro">'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:sequence minOccurs="1" maxOccurs="1">'
+
#
13
#
10
+
' <xs:element name="Exemplares">'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:sequence minOccurs="0" maxOccurs="unbounded">'
+
#
13
#
10
+
' <xs:element name="Exemplar">'
+
#
13
#
10
+
' <xs:complexType>'
+
#
13
#
10
+
' <xs:attribute name="Codigo" type="xs:string" use="required"/>'
+
#
13
#
10
+
' <xs:attribute name="OID" type="xs:int" use="required"/>'
+
#
13
#
10
+
' <xs:anyAttribute processContents="skip"/>'
+
#
13
#
10
+
' </xs:complexType>'
+
#
13
#
10
+
' </xs:element>'
+
#
13
#
10
+
' </xs:sequence>'
+
#
13
#
10
+
' <xs:anyAttribute processContents="skip"/>'
+
#
13
#
10
+
' </xs:complexType>'
+
#
13
#
10
+
' </xs:element>'
+
#
13
#
10
+
' </xs:sequence>'
+
#
13
#
10
+
' <xs:attribute name="Titulo" type="xs:string" use="required"/>'
+
#
13
#
10
+
' <xs:attribute name="Autor" type="xs:string" use="required"/>'
+
#
13
#
10
+
' <xs:attribute name="Edicao" type="xs:string" use="required"/>'
+
#
13
#
10
+
' <xs:attribute name="OID" type="xs:int" use="required"/>'
+
#
13
#
10
+
' <xs:anyAttribute processContents="skip"/>'
+
#
13
#
10
+
' </xs:complexType>'
+
#
13
#
10
+
' </xs:element>'
+
#
13
#
10
+
' </xs:sequence>'
+
#
13
#
10
+
' <xs:anyAttribute processContents="skip"/>'
+
#
13
#
10
+
' </xs:complexType>'
+
#
13
#
10
+
' </xs:element>'
+
#
13
#
10
+
'</xs:schema>'
+
#
13
#
10
+
''
;
end
;
function
GetXSDIn_3227_smucCadastrarLivro_EditandoCadastro_RM_INCLUIR_EXEMPLAR
:
String
;
function
GetXSDIn_3227_smucCadastrarLivro_EditandoCadastro_RM_INCLUIR_EXEMPLAR
:
String
;
begin
begin
Result
:=
'<?xml version="1.0"?>'
+
#
13
#
10
+
Result
:=
'<?xml version="1.0"?>'
+
#
13
#
10
+
...
@@ -3185,6 +3226,7 @@ begin
...
@@ -3185,6 +3226,7 @@ begin
lTransition
.
AddTrigger
(
'RM_CONCLUIR_EDICAO'
);
lTransition
.
AddTrigger
(
'RM_CONCLUIR_EDICAO'
);
lTransition
.
AddEffect
(
'Effect_ConcluirEdicao'
);
lTransition
.
AddEffect
(
'Effect_ConcluirEdicao'
);
lTransition
.
XsdIn
.
XML
:=
GetXSDIn_3227_smucCadastrarLivro_EditandoCadastro_RM_CONCLUIR_EDICAO
;
lTransition
.
XsdIn
.
XML
:=
GetXSDIn_3227_smucCadastrarLivro_EditandoCadastro_RM_CONCLUIR_EDICAO
;
lTransition
.
XsdOut
.
XML
:=
GetXSDOut_3227_smucCadastrarLivro_EditandoCadastro_RM_CONCLUIR_EDICAO
;
lTransition
:=
lState
.
NewOutgoingTransition
(
'RM_CANCELAR'
);
lTransition
:=
lState
.
NewOutgoingTransition
(
'RM_CANCELAR'
);
lTransition
.
SourceState
:=
lState
;
lTransition
.
SourceState
:=
lState
;
lTransition
.
TargetState
:=
lStateMachine
.
FindState
(
'SelecionandoLivro'
);
lTransition
.
TargetState
:=
lStateMachine
.
FindState
(
'SelecionandoLivro'
);
...
...
srv/src/ucu/ucuCadastrarLivro.pas
View file @
0a47ab0c
...
@@ -13,6 +13,7 @@ type
...
@@ -13,6 +13,7 @@ type
procedure
Finalize
;
Override
;
procedure
Finalize
;
Override
;
private
private
fLivro
:
ngLivro
;
fLivro
:
ngLivro
;
fSavePoint
:
acPersistenceSessionSavePoint
;
published
published
procedure
Effect_IncluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
Effect_IncluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
Effect_EditarLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
Effect_EditarLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
...
@@ -49,16 +50,65 @@ begin
...
@@ -49,16 +50,65 @@ begin
end
;
end
;
procedure
ucCadastrarLivro
.
Effect_IncluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucCadastrarLivro
.
Effect_IncluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
var
lFieldLivro
:
utField
;
begin
begin
fSavePoint
:=
Self
.
Session
.
AddSavePoint
;
try
fLivro
:=
ngLivro
.
CreateNew
(
Self
.
Session
);
lFieldLivro
:=
piRequest
.
Response
.
RootField
.
AddField
(
'Livro'
);
lFieldLivro
.
AddAttribute
(
'OID'
).
AsInteger
:=
fLivro
.
IDO
.
AsVariant
;
except
Self
.
Session
.
RollBackToSavePoint
(
fSavePoint
);
raise
;
end
;
piRequest
.
Processed
:=
True
;
piRequest
.
Processed
:=
True
;
end
;
end
;
procedure
ucCadastrarLivro
.
Effect_EditarLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucCadastrarLivro
.
Effect_EditarLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
var
lFieldLivro
,
lFieldExemplares
,
lFieldExemplar
:
utField
;
lExemplar
:
ngExemplar
;
lExemplares
:
acPersistentObjectList
;
lEnumExemplar
:
acEnumerator
;
begin
begin
fSavePoint
:=
Self
.
Session
.
AddSavePoint
;
lFieldLivro
:=
piRequest
.
Message
.
RootField
.
FieldByName
(
'Livro'
);
{Tentamos carregar o livro}
try
fLivro
:=
Self
.
Session
.
LoadObject
(
ngLivro
,
acOIDInt
.
Create
(
lFieldLivro
.
AttributeByName
(
'OID'
).
AsInteger
))
as
ngLivro
;
except
on
e
:
acObjectNotFoundException
do
raise
EucException
.
Create
(
'Livro a ser editado no pode ser encontrado.'
);
else
raise
EucException
.
Create
(
'No foi possvel editar este livro.'
);
end
;
{Retornamos o livro e todos os seus exemplares}
lExemplares
:=
fLivro
.
Exemplares
as
acPersistentObjectList
;
lFieldLivro
:=
piRequest
.
Response
.
RootField
.
AddField
(
'Livro'
);
fLivro
.
toXML
(
lFieldLivro
);
lFieldExemplares
:=
lFieldLivro
.
AddField
(
'Exemplares'
);
lEnumExemplar
:=
acEnumerator
.
Create
(
lExemplares
);
while
not
lEnumExemplar
.
EOL
do
begin
lFieldExemplar
:=
lFieldExemplares
.
AddField
(
'Exemplar'
);
lExemplar
:=
lEnumExemplar
.
Current
;
lExemplar
.
toXML
(
lFieldExemplar
);
lEnumExemplar
.
MoveNext
;
end
;
piRequest
.
Processed
:=
True
;
piRequest
.
Processed
:=
True
;
end
;
end
;
...
@@ -115,20 +165,39 @@ end;
...
@@ -115,20 +165,39 @@ end;
{Se ele possuir exemplares, eles sero deletados juntos com o livro.}
{Se ele possuir exemplares, eles sero deletados juntos com o livro.}
procedure
ucCadastrarLivro
.
Effect_ExcluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucCadastrarLivro
.
Effect_ExcluirLivro
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
var
var
lFieldLivro
:
utField
;
lFieldLivro
,
lFieldResult
:
utField
;
lLivro
:
ngLivro
;
lLivro
:
ngLivro
;
lListExemplares
:
acPersistentObjectList
;
lListExemplares
:
acPersistentObjectList
;
lOQL
:
IContarEmprestimosLivro
;
lSavePoint
:
acPersistenceSessionSavePoint
;
begin
begin
lFieldLivro
:=
piRequest
.
Message
.
RootField
.
FieldByName
(
'Livro'
);
lFieldLivro
:=
piRequest
.
Message
.
RootField
.
FieldByName
(
'Livro'
);
lSavePoint
:=
Session
.
AddSavePoint
;
try
try
lLivro
:=
Self
.
Session
.
LoadObject
(
ngLivro
,
acOIDInt
.
Create
(
lFieldLivro
.
AttributeByName
(
'OID'
).
AsInteger
))
as
ngLivro
;
{Preparamos a busca OQL}
Self
.
Session
.
DeleteObject
(
lLivro
,
ngLivro
);
lOQL
:=
utEmprestimoOQL
.
ContarEmprestimosLivro
(
Self
.
Session
);
lOQL
.
Param_oid
.
Value
:=
lFieldLivro
.
AttributeByName
(
'OID'
).
AsInteger
;
lFieldResult
:=
utField
.
Create
;
try
{Verificamos se ele tiver emprestimos}
lOQL
.
LoadDataSet
(
lFieldResult
);
if
lFieldResult
.
ValueByPath
(
'DATAPACKET.ROWDATA.ROW.@C0'
).
AsInteger
>
0
then
raise
EucException
.
Create
(
'Nao foi possvel excluir o livro, ele possui pelo menos um exemplar com emprstimo associado.'
);
{Deletamos o livro e seus exemplares, exemplares so deletado devido a efeito cascata da composio}
lLivro
:=
Self
.
Session
.
LoadObject
(
ngLivro
,
acOIDInt
.
Create
(
lFieldLivro
.
AttributeByName
(
'OID'
).
AsInteger
))
as
ngLivro
;
Self
.
Session
.
DeleteObject
(
lLivro
);
Self
.
Session
.
Save
;
finally
lFieldResult
.
Free
;
end
;
except
except
on
e
:
acObjectNotFoundException
do
Self
.
Session
.
RollBackToSavePoint
(
lSavePoint
);
raise
EucException
.
Create
(
'Livro a ser deletado no encontrado.'
);
raise
;
else
raise
EucException
.
Create
(
'No foi possvel buscar o Livro a ser deletado.'
);
end
;
end
;
piRequest
.
Processed
:=
True
;
piRequest
.
Processed
:=
True
;
...
@@ -136,15 +205,14 @@ end;
...
@@ -136,15 +205,14 @@ end;
procedure
ucCadastrarLivro
.
Effect_ConcluirEdicao
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucCadastrarLivro
.
Effect_ConcluirEdicao
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
begin
begin
piRequest
.
Processed
:=
True
;
end
;
end
;
procedure
ucCadastrarLivro
.
Effect_Cancelar
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
procedure
ucCadastrarLivro
.
Effect_Cancelar
(
piRequest
:
utRequest
;
piTransition
:
utTransition
);
begin
begin
if
Assigned
(
fSavePoint
)
then
Session
.
RollBackToSavePoint
(
fSavePoint
);
piRequest
.
Processed
:=
True
;
piRequest
.
Processed
:=
True
;
end
;
end
;
...
...
srv/src/utu/utuEmprestimoOQL.pas
View file @
0a47ab0c
...
@@ -6,6 +6,14 @@ uses acuOQL, acuFramework;
...
@@ -6,6 +6,14 @@ uses acuOQL, acuFramework;
type
type
IContarEmprestimosExemplar
=
interface
(
IDataSetOQLQuery
)
function
Param_oid
:
acOQLParamInt
;
end
;
IContarEmprestimosLivro
=
interface
(
IDataSetOQLQuery
)
function
Param_oid
:
acOQLParamInt
;
end
;
IObterClientes
=
interface
(
IOQLQuery
)
IObterClientes
=
interface
(
IOQLQuery
)
function
Param_nome
:
acOQLParamString
;
function
Param_nome
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
...
@@ -27,6 +35,8 @@ type
...
@@ -27,6 +35,8 @@ type
end
;
end
;
utEmprestimoOQL
=
class
utEmprestimoOQL
=
class
class
function
ContarEmprestimosExemplar
(
piSessao
:
acPersistenceSession
):
IContarEmprestimosExemplar
;
class
function
ContarEmprestimosLivro
(
piSessao
:
acPersistenceSession
):
IContarEmprestimosLivro
;
class
function
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
class
function
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
class
function
ObterEmprestimos
(
piSessao
:
acPersistenceSession
):
IObterEmprestimos
;
class
function
ObterEmprestimos
(
piSessao
:
acPersistenceSession
):
IObterEmprestimos
;
class
function
ObterExemplares
(
piSessao
:
acPersistenceSession
):
IObterExemplares
;
class
function
ObterExemplares
(
piSessao
:
acPersistenceSession
):
IObterExemplares
;
...
@@ -37,6 +47,14 @@ implementation
...
@@ -37,6 +47,14 @@ implementation
type
type
TContarEmprestimosExemplar
=
class
(
acDataSetOQLQuery
,
IContarEmprestimosExemplar
)
function
Param_oid
:
acOQLParamInt
;
end
;
TContarEmprestimosLivro
=
class
(
acDataSetOQLQuery
,
IContarEmprestimosLivro
)
function
Param_oid
:
acOQLParamInt
;
end
;
TObterClientes
=
class
(
acOQLQuery
,
IObterClientes
)
TObterClientes
=
class
(
acOQLQuery
,
IObterClientes
)
function
Param_nome
:
acOQLParamString
;
function
Param_nome
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
function
Param_cpf
:
acOQLParamString
;
...
@@ -57,6 +75,20 @@ type
...
@@ -57,6 +75,20 @@ type
function
Param_autor
:
acOQLParamString
;
function
Param_autor
:
acOQLParamString
;
end
;
end
;
{ TContarEmprestimosExemplar }
function
TContarEmprestimosExemplar
.
Param_oid
:
acOQLParamInt
;
begin
result
:=
acOQLParamInt
(
Self
.
ParamByName
(
'oid'
));
end
;
{ TContarEmprestimosLivro }
function
TContarEmprestimosLivro
.
Param_oid
:
acOQLParamInt
;
begin
result
:=
acOQLParamInt
(
Self
.
ParamByName
(
'oid'
));
end
;
{ TObterClientes }
{ TObterClientes }
function
TObterClientes
.
Param_nome
:
acOQLParamString
;
function
TObterClientes
.
Param_nome
:
acOQLParamString
;
...
@@ -107,6 +139,25 @@ end;
...
@@ -107,6 +139,25 @@ end;
{ utOQLs }
{ utOQLs }
class
function
utEmprestimoOQL
.
ContarEmprestimosExemplar
(
piSessao
:
acPersistenceSession
):
IContarEmprestimosExemplar
;
begin
result
:=
TContarEmprestimosExemplar
.
Create
(
pisessao
,
'SELECT count(*) as qnt'
+
#
13
#
10
+
'FROM ngExemplar,'
+
#
13
#
10
+
' ngExemplar.Emprestimos'
+
#
13
#
10
+
'WHERE ngExemplar.OID = ?oid:acInt'
);
end
;
class
function
utEmprestimoOQL
.
ContarEmprestimosLivro
(
piSessao
:
acPersistenceSession
):
IContarEmprestimosLivro
;
begin
result
:=
TContarEmprestimosLivro
.
Create
(
pisessao
,
'SELECT count(*) as qnt'
+
#
13
#
10
+
'FROM ngLivro,'
+
#
13
#
10
+
' ngLivro.Exemplares,'
+
#
13
#
10
+
' ngLivro.Exemplares.Emprestimos'
+
#
13
#
10
+
'WHERE ngLivro.OID = ?oid:acInt'
);
end
;
class
function
utEmprestimoOQL
.
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
class
function
utEmprestimoOQL
.
ObterClientes
(
piSessao
:
acPersistenceSession
):
IObterClientes
;
begin
begin
result
:=
TObterClientes
.
Create
(
pisessao
,
result
:=
TObterClientes
.
Create
(
pisessao
,
...
...
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