@ -245,7 +245,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
}
}
}
}
protected void approve ( T entity , User user , Date approveDate ) {
protected void approve ( T entity , User user , Date approveDate , byte [ ] signedPdf ) {
T e = ( T ) dao . getById ( entity . getId ( ) ) ;
T e = ( T ) dao . getById ( entity . getId ( ) ) ;
if ( e . getReqDate ( ) . getTime ( ) > approveDate . getTime ( ) ) {
if ( e . getReqDate ( ) . getTime ( ) > approveDate . getTime ( ) ) {
@ -300,12 +300,16 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
}
}
}
}
saveSignedDoc ( e ) ;
if ( signedPdf ! = null )
{
saveSignedDoc ( e , signedPdf ) ;
}
postApprove ( e ) ;
postApprove ( e ) ;
}
}
protected void approve ( T entity , User user ) {
protected void approve ( T entity , User user ) {
approve ( entity , user , new Date ( ) );
approve ( entity , user , new Date ( ) , null );
}
}
@Override
@Override
@ -318,8 +322,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@Override
@Override
@Transactional
@Transactional
@PreAuthorize ( "this.canApprove(#entity)" )
@PreAuthorize ( "this.canApprove(#entity)" )
public void approve ( T entity , Date approveDate ) {
public void approve ( T entity , Date approveDate , byte [ ] signedPdf ) {
approve ( entity , getLoggedInUser ( ) , approveDate );
approve ( entity , getLoggedInUser ( ) , approveDate , signedPdf );
}
}
/ * *
/ * *
@ -342,33 +346,27 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
}
}
protected void saveSignedDoc ( T entity ) {
protected void saveSignedDoc ( T entity , byte [ ] signedPdf ) {
/ *
DataModel reportEntity = entityForSignReport ( entity ) ;
if ( ! entity . equals ( reportDefinition . getDataSet ( ) . get ( 0 ) ) ) {
SignedDocumentItem signedItem = signedDocumentService . getItem ( entityForSignReport ( entity ) , getSignReport ( entity ) . getReportId ( ) ) ;
throw new ApproveException ( ) ;
} * /
DataModel reportEntity = ( DataModel ) reportDefinition . getDataSet ( ) . get ( 0 ) ;
SignedDocumentItem signedItem = signedDocumentService . getItem ( entity , reportDefinition . getReport ( ) . getReportId ( ) ) ;
SignData data = ( SignData ) sessionData . getProperty ( Constants . KEY_SIGN_DATA ) ;
if ( signedItem = = null ) {
if ( signedItem = = null ) {
data = ( SignData ) sessionData . getProperty ( Constants . KEY_SIGN_DATA ) ;
SignedDocument signDoc = new SignedDocument ( ) ;
SignedDocument signDoc = new SignedDocument ( ) ;
signDoc . setDescription ( entity . getDescription ( ) ) ;
signDoc . setDescription ( entity . getDescription ( ) ) ;
signDoc . setNumser ( entity . getNumser ( ) ) ;
signDoc . setNumser ( entity . getNumser ( ) ) ;
signDoc . setRecordId ( reportEntity . getId ( ) ) ;
signDoc . setRecordId ( reportEntity . getId ( ) ) ;
signDoc . setModuleName ( ModuleUtils . getModule ( reportEntity , servletContext ) . getId ( ) ) ;
signDoc . setModuleName ( ModuleUtils . getModule ( reportEntity , servletContext ) . getId ( ) ) ;
signDoc . setSignDate ( entity . getLastApproveDate ( ) ) ;
SignedDocumentItem item = new SignedDocumentItem ( ) ;
SignedDocumentItem item = new SignedDocumentItem ( ) ;
item . setReportId ( reportDefinition . getReport ( ) . getReportId ( ) ) ;
item . setReportId ( reportDefinition . getReport ( ) . getReportId ( ) ) ;
item . setReportName ( reportDefinition . getReport ( ) . getName ( ) ) ;
item . setReportName ( reportDefinition . getReport ( ) . getName ( ) ) ;
signDoc . addItem ( item ) ;
signDoc . addItem ( item ) ;
signedDocStorage . saveFile ( data. getPdfData ( ) , item ) ;
signedDocStorage . saveFile ( signedPdf , item ) ;
signedDocumentService . addFromApprove ( signDoc ) ;
signedDocumentService . addFromApprove ( signDoc ) ;
} else {
} else {
signedDocStorage . saveFile ( data. getPdfData ( ) , signedItem ) ;
signedDocStorage . saveFile ( signedPdf , signedItem ) ;
}
}
}
}
@ -478,23 +476,16 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
sessionData . setProperty ( Constants . KEY_SIGN_GUID , data . getSignGuid ( ) ) ;
sessionData . setProperty ( Constants . KEY_SIGN_GUID , data . getSignGuid ( ) ) ;
reportDefinition . clear ( ) ;
reportDefinition . clear ( ) ;
reportDefinition . setSingleObject ( entityForReport ( entity ) ) ;
reportDefinition . setSingleObject ( entityForSignReport ( entity ) ) ;
Module module = ModuleUtils . getModule ( entityForReport ( entity ) , servletContext ) ;
Report report = null ;
for ( Report r : module . getReports ( ) ) {
Report report = getSignReport ( entity ) ;
if ( r . isSignable ( ) ) {
report = r ;
break ;
}
}
if ( report = = null ) {
if ( report = = null ) {
return false ;
return false ;
}
}
reportDefinition . setReport ( report ) ;
reportDefinition . setReport ( report ) ;
Module module = ModuleUtils . getModule ( entityForSignReport ( entity ) , servletContext ) ;
reportDefinition . setService ( ( Service < Object > ) ModuleUtils . getServiceInstance ( module , servletContext ) ) ;
reportDefinition . setService ( ( Service < Object > ) ModuleUtils . getServiceInstance ( module , servletContext ) ) ;
paramFiller . fill ( ) ;
paramFiller . fill ( ) ;
@ -503,7 +494,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
data . setDescription ( entity . getDescription ( ) ) ;
data . setDescription ( entity . getDescription ( ) ) ;
data . setNumser ( entity . getNumser ( ) ) ;
data . setNumser ( entity . getNumser ( ) ) ;
data . setSignDate ( approveDate ) ;
data . setSignDate ( approveDate ) ;
data . setSigned ( signedDocumentService . getItem ( entityFor Report( entity ) , report . getReportId ( ) ) ! = null ) ;
data . setSigned ( signedDocumentService . getItem ( entityFor Sign Report( entity ) , report . getReportId ( ) ) ! = null ) ;
if ( entity . getState ( ) = = RequirementState . NEW ) {
if ( entity . getState ( ) = = RequirementState . NEW ) {
data . setAreaId ( 1 ) ;
data . setAreaId ( 1 ) ;
@ -512,12 +503,28 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
data . setAreaId ( entity . getAuthorization ( ) . size ( ) + 1 ) ;
data . setAreaId ( entity . getAuthorization ( ) . size ( ) + 1 ) ;
}
}
if ( userService . getUserSettings ( ) . getSignatureFile ( ) ! = null ) {
data . setSignImg ( storage . fileData ( userService . getUserSettings ( ) . getSignatureFile ( ) ) ) ;
data . setSignImg ( storage . fileData ( userService . getUserSettings ( ) . getSignatureFile ( ) ) ) ;
}
return true ;
return true ;
}
}
protected DataModel entityFor Report( T entity ) {
protected DataModel entityFor Sign Report( T entity ) {
return entity ;
return entity ;
}
}
private Report getSignReport ( T entity ) {
Module module = ModuleUtils . getModule ( entityForSignReport ( entity ) , servletContext ) ;
Report report = null ;
for ( Report r : module . getReports ( ) ) {
if ( r . isSignable ( ) ) {
report = r ;
break ;
}
}
return report ;
}
}
}