666 whereStatement.Append( KAnd ); |
666 whereStatement.Append( KAnd ); |
667 whereStatement.AppendFormat( KSQLGetEntryTypeNames, |
667 whereStatement.AppendFormat( KSQLGetEntryTypeNames, |
668 &typeNameWhereStatement ); |
668 &typeNameWhereStatement ); |
669 CleanupStack::PopAndDestroy( &typeNameWhereStatement ); |
669 CleanupStack::PopAndDestroy( &typeNameWhereStatement ); |
670 } |
670 } |
|
671 |
|
672 if( aQuery->GetAttributes().Count() ) |
|
673 { |
|
674 RBuf whereAttributes; |
|
675 whereAttributes.CleanupClosePushL(); |
|
676 whereAttributes.CreateL( KEmpty ); |
|
677 |
|
678 for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ ) |
|
679 { |
|
680 // at1.AT_NAME = 'Attribute_Name_1' AND at1.AT_VALUE = 'Attribute_VALUE_1' |
|
681 TPtrC atrName( aQuery->GetAttributes().operator [](j-1)->Name() ); |
|
682 TPtrC atrValue( aQuery->GetAttributes().operator [](j-1)->Value() ); |
|
683 |
|
684 whereAttributes.ReAllocL( whereAttributes.Length() + 2 * KAnd().Length() + |
|
685 4 * KSingleQuotes().Length() + |
|
686 2 * KMaxIntNumLength + |
|
687 2 * KAt().Length() + 2 * KDot().Length() + 2 * KEqual().Length() + |
|
688 KColumnAttrName().Length() + KColumnAttrValue().Length() + |
|
689 atrName.Length() + atrValue.Length() ); |
|
690 |
|
691 whereAttributes.Append( KAnd ); |
|
692 |
|
693 whereAttributes.Append( KAt ); |
|
694 whereAttributes.AppendNum( j ); |
|
695 whereAttributes.Append( KDot ); |
|
696 whereAttributes.Append( KColumnAttrName ); |
|
697 whereAttributes.Append( KEqual ); |
|
698 whereAttributes.Append( KSingleQuotes ); |
|
699 whereAttributes.Append( atrName ); |
|
700 whereAttributes.Append( KSingleQuotes ); |
|
701 |
|
702 whereAttributes.Append( KAnd ); |
|
703 |
|
704 whereAttributes.Append( KAt ); |
|
705 whereAttributes.AppendNum( j ); |
|
706 whereAttributes.Append( KDot ); |
|
707 whereAttributes.Append( KColumnAttrValue ); |
|
708 whereAttributes.Append( KEqual ); |
|
709 whereAttributes.Append( KSingleQuotes ); |
|
710 whereAttributes.Append( atrValue ); |
|
711 whereAttributes.Append( KSingleQuotes ); |
|
712 |
|
713 } |
|
714 |
|
715 whereStatement.ReAllocL( whereStatement.Length() + whereAttributes.Length() ); |
|
716 whereStatement.Append( whereAttributes ); |
|
717 |
|
718 CleanupStack::PopAndDestroy( &whereAttributes ); |
|
719 } |
|
720 |
|
721 RBuf leftJoins; |
|
722 leftJoins.CleanupClosePushL(); |
|
723 leftJoins.CreateL( KEmpty ); |
|
724 if( aQuery->GetAttributes().Count() ) |
|
725 { |
|
726 for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ ) |
|
727 { |
|
728 // LEFT JOIN CA_ATTRIBUTE as at1 ON ENTRY_ID = at1.AT_ENTRY_ID |
|
729 leftJoins.ReAllocL( leftJoins.Length() + |
|
730 KLeftJoinCaAttrubute1().Length() + KMaxIntNumLength + |
|
731 KLeftJoinCaAttrubute2().Length() + KMaxIntNumLength + |
|
732 KLeftJoinCaAttrubute3().Length() |
|
733 ); |
|
734 |
|
735 leftJoins.Append( KLeftJoinCaAttrubute1 ); |
|
736 leftJoins.AppendNum( j ); |
|
737 leftJoins.Append( KLeftJoinCaAttrubute2 ); |
|
738 leftJoins.AppendNum( j ); |
|
739 leftJoins.Append( KLeftJoinCaAttrubute3 ); |
|
740 } |
|
741 } |
|
742 |
|
743 |
|
744 whereStatement.ReAllocL( whereStatement.Length() + |
|
745 KGroupBy().Length() + KColumnEntryId().Length() ); |
|
746 whereStatement.Append( KGroupBy ); |
|
747 whereStatement.Append( KColumnEntryId ); |
671 |
748 |
672 TInt groupId = aQuery->GetParentId(); |
749 TInt groupId = aQuery->GetParentId(); |
673 RBuf query; |
750 RBuf query; |
674 query.CleanupClosePushL(); |
751 query.CleanupClosePushL(); |
675 if( groupId > 0 ) |
752 if( groupId > 0 ) |
676 { |
753 { |
677 query.CreateL( KSQLGetListByParentId().Length() |
754 RBuf getListByParentId2withWhere; |
678 + whereStatement.Length() - 2 ); |
755 getListByParentId2withWhere.CleanupClosePushL(); |
679 query.AppendFormat( KSQLGetListByParentId, &whereStatement ); |
756 getListByParentId2withWhere.CreateL( KSQLGetListByParentId2().Length() + whereStatement.Length() ); |
|
757 getListByParentId2withWhere.AppendFormat( KSQLGetListByParentId2, &whereStatement ); |
|
758 |
|
759 query.ReAllocL( KSQLGetListByParentId1().Length() + leftJoins.Length() + |
|
760 getListByParentId2withWhere.Length() ); |
|
761 query.Append( KSQLGetListByParentId1 ); |
|
762 query.Append( leftJoins ); |
|
763 query.Append( getListByParentId2withWhere ); |
|
764 CleanupStack::PopAndDestroy( &getListByParentId2withWhere ); |
680 } |
765 } |
681 else |
766 else |
682 { |
767 { |
683 query.CreateL( KSQLGetList().Length() ); |
768 query.CreateL( KSQLGetList1().Length() ); |
684 query.Append( KSQLGetList ); |
769 query.Append( KSQLGetList1 ); |
|
770 query.ReAllocL( query.Length() + leftJoins.Length() + KSQLGetList2().Length() ); |
|
771 query.Append( leftJoins ); |
|
772 query.Append( KSQLGetList2 ); |
685 if( whereStatement.Length() >= KAnd().Length() ) |
773 if( whereStatement.Length() >= KAnd().Length() ) |
686 { |
774 { |
687 TPtrC ptrWhereStatement( whereStatement.Right( |
775 TPtrC ptrWhereStatement( whereStatement.Right( |
688 whereStatement.Length() - KAnd().Length() ) ); |
776 whereStatement.Length() - KAnd().Length() ) ); |
689 query.ReAllocL( KSQLGetList().Length() + KWhere().Length() |
777 query.ReAllocL( query.Length() + KWhere().Length() |
690 + ptrWhereStatement.Length() ); |
778 + ptrWhereStatement.Length() ); |
|
779 |
691 query.Append( KWhere ); |
780 query.Append( KWhere ); |
692 query.Append( ptrWhereStatement ); |
781 query.Append( ptrWhereStatement ); |
693 } |
782 } |
694 } |
783 } |
695 |
784 |