Examples of OneToOneAssociation


Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

    }

    @Override
    public ObjectAdapter that(final PerformContext performContext) throws ScenarioBoundValueException {

        final OneToOneAssociation otoa = (OneToOneAssociation) performContext.getObjectMember();

        // if we have an expected result
        final CellBinding arg0Binding = performContext.getPeer().getArg0Binding();
        final ScenarioCell arg0Cell = arg0Binding.getCurrentCell();
        final String expected = arg0Cell.getText();

        // get
        final ObjectAdapter resultAdapter = otoa.get(performContext.getOnAdapter());

        // see if matches null
        if (resultAdapter == null) {
            // ok
            return null;
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

    // header
    // ///////////////////////////////////////////////////////////////////////

    public PropertyResult definePropertyOrAlias(final String heading, final int colNum) {

        OneToOneAssociation otoa = null;

        try {
            final int aliasColumn = getAliasBinding().getColumn();
            if (colNum == aliasColumn) {
                return PropertyResult.ALIAS;
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

        return getPersistenceSession().createTransientInstance(spec);
    }

    public SetUpObjectResult setUpProperty(final ObjectAdapter adapter, final int colNum) {

        final OneToOneAssociation association = getProperties().get(colNum);
        if (association == null) {
            return SetUpObjectResult.NO_ASSOCIATION;
        }

        final String cellText = cellTextList.get(colNum);

        // handle empty cell as null
        if (cellText == null || cellText.length() == 0) {

            // use clear facet if available
            final PropertyClearFacet clearFacet = association.getFacet(PropertyClearFacet.class);

            if (clearFacet != null) {
                clearFacet.clearProperty(adapter);
                return SetUpObjectResult.CLEARED;
            }

            // use setter facet otherwise
            final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);

            if (setterFacet != null) {
                setterFacet.setProperty(adapter, null);
                return SetUpObjectResult.CLEARED;
            }

            return SetUpObjectResult.CANNOT_CLEAR;
        }

        // non-empty, will need a setter
        final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);
        if (setterFacet == null) {
            return SetUpObjectResult.CANNOT_SET;
        }

        final ObjectSpecification fieldSpecification = association.getSpecification();
        final ParseableFacet parseableFacet = fieldSpecification.getFacet(ParseableFacet.class);

        ObjectAdapter referencedAdapter = null;
        if (parseableFacet != null) {
            // handle as parseable value
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

        }
    }

    public void forEachAssociation(final AssociationVisitor visitor) {
        for (int colNum = 0; colNum < getProperties().size(); colNum++) {
            final OneToOneAssociation association = getProperties().get(colNum);
            if (association != null) {
                visitor.visit(association, colNum);
            }
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

        final Class<?> cls = objectSpec.getCorrespondingClass();
        if(!JdoPropertyUtils.hasPrimaryKeyProperty(objectSpec)) {
            throw new UnsupportedOperationException("cannot search by primary key for DataStore-assigned entities");
        }
        final OneToOneAssociation pkOtoa = JdoPropertyUtils.getPrimaryKeyPropertyFor(objectSpec);
        final String pkOtoaId = pkOtoa.getId();
        final String filter = pkOtoaId + "==" + map.get(pkOtoaId);
        final Query jdoQuery = getPersistenceManager().newQuery(cls, filter);

        // http://www.datanucleus.org/servlet/jira/browse/NUCCORE-1103
        jdoQuery.addExtension("datanucleus.multivaluedFetch", "none");
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

            if (intent == Intent.CHECK_IF_VALID || intent == Intent.MODIFY_PROPERTY_SUPPORTING) {
                throw new UnsupportedOperationException(String.format("Cannot invoke supporting method for '%s'; use only property accessor/mutator", memberName));
            }

            final OneToOneAssociation otoa = (OneToOneAssociation) objectMember;
           
            if (intent == Intent.ACCESSOR) {
                return handleGetterMethodOnProperty(args, targetAdapter, otoa, methodName);
            }
           
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

            if (association.isOneToManyAssociation()) {
                final OneToManyAssociation oneToManyAssociation = (OneToManyAssociation) association;
                final ObjectAdapter collectionAdapter = fieldAdapter; // to explain
                writeCollection(writer, oneToManyAssociation, collectionAdapter);
            } else {
                final OneToOneAssociation oneToOneAssociation = (OneToOneAssociation) association;
                final ObjectAdapter propertyAdapter = fieldAdapter; // to explain
                writeProperty(writer, oneToOneAssociation, propertyAdapter);
            }
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

        final boolean openForObjectsWithOutReferences = true;
        return openForObjectsWithOutReferences ? CAN_OPEN : CANT_OPEN;
    }

    private boolean fieldContainsReference(final ObjectAdapter parent, final ObjectAssociation field) {
        final OneToOneAssociation association = (OneToOneAssociation) field;
        final OneToOneFieldImpl fieldContent = new OneToOneFieldImpl(parent, field.get(parent), association);
        if (openViewSpecification.canDisplay(new ViewRequirement(fieldContent, ViewRequirement.OPEN))) {
            return true;
        }
        return false;
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

    // getInstance
    // /////////////////////////////////////////////////////////////

    @Override
    public Instance getInstance(final ObjectAdapter ownerAdapter) {
        final OneToOneAssociation specification = this;
        return ownerAdapter.getInstance(specification);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

        final List<ObjectAssociation> properties = objectSpec.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.PROPERTIES);

        boolean allOk = true;

        for (final ObjectAssociation association : properties) {
            final OneToOneAssociation property = (OneToOneAssociation) association;
            final ObjectSpecification propertySpec = property.getSpecification();
            final String id = property.getId();
            final JsonRepresentation propertyRepr = propertiesList.getRepresentation(id);
            final Consent visibility = property.isVisible(resourceContext.getAuthenticationSession() , objectAdapter, resourceContext.getWhere());
            final Consent usability = property.isUsable(resourceContext.getAuthenticationSession() , objectAdapter, resourceContext.getWhere());

            final boolean invisible = visibility.isVetoed();
            final boolean disabled = usability.isVetoed();
            final boolean valueProvided = propertyRepr != null;

            if(!valueProvided) {

                // no value provided

                if(invisible || disabled) {
                    // that's ok, indeed expected
                    continue;
                }
                if (!property.isMandatory()) {
                    // optional, so also not a problem
                    continue;
                }

                // otherwise, is an error.
                final String invalidReason = propertiesList.getString("x-ro-invalidReason");
                if(invalidReason != null) {
                    propertiesList.mapPut("x-ro-invalidReason", invalidReason + "; " + property.getName());
                } else {
                    propertiesList.mapPut("x-ro-invalidReason", "Mandatory field(s) missing: " + property.getName());
                }
                allOk = false;
                continue;

            } else {

                // value has been provided
                if (invisible) {
                    // silently ignore; don't want to acknowledge the existence of this property to the caller
                    continue;
                }
                if (disabled) {
                    // not allowed to update
                    propertyRepr.mapPut("invalidReason", usability.getReason());
                    allOk = false;
                    continue;
                }

                // ok, we have a value, and the property is not invisible, and is not disabled
                final ObjectAdapter valueAdapter;
                try {
                    valueAdapter = new JsonParserHelper(resourceContext, propertySpec).objectAdapterFor(propertyRepr);
                } catch(IllegalArgumentException ex) {
                    propertyRepr.mapPut("invalidReason", ex.getMessage());
                    allOk = false;
                    continue;
                }
                // check if the proposed value is valid
                final Consent validity = property.isAssociationValid(objectAdapter, valueAdapter);
                if (validity.isAllowed()) {
                    try {
                        property.set(objectAdapter, valueAdapter);
                    } catch (final IllegalArgumentException ex) {
                        propertyRepr.mapPut("invalidReason", ex.getMessage());
                        allOk = false;
                    }
                } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.