Java Code Examples for com.gs.fw.common.mithra.finder.RelatedFinder#getSourceAttribute()

The following examples show how to use com.gs.fw.common.mithra.finder.RelatedFinder#getSourceAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultLoadOperationProvider.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public List<Operation> getOperationsForFullCacheLoad(RelatedFinder finder)
{
    if (finder.getSourceAttribute() != null)
    {
        throw new RuntimeException("for full cache load of objects with source attribute, configure a loadOperationProvider in the runtime xml");
    }
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    if (asOfAttributes != null)
    {
        Operation op = asOfAttributes[0].equalsEdgePoint();
        if (asOfAttributes.length > 1)
        {
            op = op.and(asOfAttributes[1].equalsEdgePoint());
        }
        return ListFactory.create(op);
    }
    else
    {
        return ListFactory.create(finder.all());
    }
}
 
Example 2
Source File: FastUnsafeOffHeapDataStorage.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void populateStringAttributes(RelatedFinder finder)
{
    Attribute[] persistentAttributes = finder.getPersistentAttributes();
    List<OffHeapStringExtractor> tmp = MithraFastList.newList();
    Attribute sourceAttribute = finder.getSourceAttribute();
    if (sourceAttribute != null && sourceAttribute instanceof SingleColumnStringAttribute)
    {
        tmp.add((OffHeapStringExtractor) sourceAttribute.zCreateOffHeapExtractor());
    }
    for(Attribute a: persistentAttributes)
    {
        if (a instanceof SingleColumnStringAttribute)
        {
            tmp.add((OffHeapStringExtractor) a.zCreateOffHeapExtractor());
        }
    }
    stringAttributes = tmp.toArray(new OffHeapStringExtractor[tmp.size()]);
}
 
Example 3
Source File: DbExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static Attribute[] getPrimaryKeyAttributesWithNoSource(RelatedFinder finder)
{
    Attribute sourceAttribute = finder.getSourceAttribute();
    Attribute[] primaryKeyAttributes = finder.getPrimaryKeyAttributes();
    if (sourceAttribute == null)
    {
        return primaryKeyAttributes;
    }
    int sourceLength = sourceAttribute == null ? 0 : 1;
    Attribute[] attributes = new Attribute[primaryKeyAttributes.length - sourceLength];
    int index = 0;
    for (Attribute pkAttr : primaryKeyAttributes)
    {
        if (!pkAttr.equals(sourceAttribute))
        {
            attributes[index++] = pkAttr;
        }
    }
    return attributes;
}
 
Example 4
Source File: DbExtractor.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private static Attribute[] getSourcelessPrimaryKeyWithFromAttributes(RelatedFinder finder)
{
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    Attribute sourceAttribute = finder.getSourceAttribute();
    Attribute[] primaryKeyAttributes = finder.getPrimaryKeyAttributes();
    if (asOfAttributes == null && sourceAttribute == null)
    {
        return primaryKeyAttributes;
    }
    int asOfLength = asOfAttributes == null ? 0 : asOfAttributes.length;
    int sourceLength = sourceAttribute == null ? 0 : 1;
    Attribute[] attributes = new Attribute[primaryKeyAttributes.length + asOfLength - sourceLength];
    int index = 0;
    for (Attribute pkAttr : primaryKeyAttributes)
    {
        if (!pkAttr.equals(sourceAttribute))
        {
            attributes[index++] = pkAttr;
        }
    }
    if (asOfAttributes != null)
    {
        for (AsOfAttribute asOfAttr : asOfAttributes)
        {
            attributes[index++] = asOfAttr.getFromAttribute();
        }
    }
    return attributes;
}
 
Example 5
Source File: DelegatingList.java    From reladomo with Apache License 2.0 4 votes vote down vote up
protected void forceRefreshForSimpleList()
{
    if (this.size() == 0)
    {
        return;
    }
    RelatedFinder finder = this.getMithraObjectPortal().getFinder();
    Attribute[] pkAttributes = finder.getPrimaryKeyAttributes();
    Attribute sourceAttribute = finder.getSourceAttribute();
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    MithraTransaction tx = MithraManagerProvider.getMithraManager().getCurrentTransaction();
    boolean oldEvaluationMode = tx != null && tx.zIsInOperationEvaluationMode();
    if (asOfAttributes != null)
    {
        List<? extends List> segregatedByDate;
        try
        {
            if (tx != null) tx.zSetOperationEvaluationMode(true);
            segregatedByDate = segregateByAsOfAttribute(asOfAttributes);
        }
        finally
        {
            if (tx != null) tx.zSetOperationEvaluationMode(oldEvaluationMode);
        }
        for (int i = 0; i < segregatedByDate.size(); i++)
        {
            List list = segregatedByDate.get(i);
            Operation dateOp;
            try
            {
                if (tx != null) tx.zSetOperationEvaluationMode(true);
                dateOp = asOfAttributes[0].nonPrimitiveEq(asOfAttributes[0].valueOf(list.get(0)));
                if (asOfAttributes.length == 2)
                {
                    dateOp = dateOp.and(asOfAttributes[1].nonPrimitiveEq(asOfAttributes[1].valueOf(list.get(0))));
                }
            }
            finally
            {
                if (tx != null)
                {
                    tx.zSetOperationEvaluationMode(oldEvaluationMode);
                }
            }
            if (pkAttributes.length == 1 || (pkAttributes.length == 2 && sourceAttribute != null))
            {
                forceRefreshWithOnePk(list, pkAttributes, dateOp, tx, oldEvaluationMode);
            }
            else
            {
                forceRefreshWithMultiplePk(list, pkAttributes, dateOp, tx, oldEvaluationMode);
            }
        }
    }
    else
    {
        if (pkAttributes.length == 1 || (pkAttributes.length == 2 && sourceAttribute != null))
        {
            forceRefreshWithOnePk(this, pkAttributes, null, tx, oldEvaluationMode);
        }
        else
        {
            forceRefreshWithMultiplePk(this, pkAttributes, null, tx, oldEvaluationMode);
        }
    }
}