Package org.apache.isis.core.metamodel.spec.feature

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


    // get{MemberType}ThatIsVisibleAndUsable
    // ///////////////////////////////////////////////////////////////////

    protected OneToOneAssociation getPropertyThatIsVisibleForIntent(final String propertyId, final Intent intent, Where where) {

        final ObjectAssociation association;
        try {
            final ObjectSpecification specification = objectAdapter.getSpecification();
            association = specification.getAssociation(propertyId);
        } catch(Exception ex) {
            // fall through
            throwNotFoundException(propertyId, MemberType.PROPERTY);
            return null; // to keep compiler happy.
        }

        if (association == null || !association.isOneToOneAssociation()) {
            throwNotFoundException(propertyId, MemberType.PROPERTY);
        }
       
        final OneToOneAssociation property = (OneToOneAssociation) association;
        return memberThatIsVisibleForIntent(property, MemberType.PROPERTY, intent, where);
View Full Code Here


        return memberThatIsVisibleForIntent(property, MemberType.PROPERTY, intent, where);
    }

    protected OneToManyAssociation getCollectionThatIsVisibleForIntent(final String collectionId, final Intent intent, Where where) {

        final ObjectAssociation association;
        try {
            final ObjectSpecification specification = objectAdapter.getSpecification();
            association = specification.getAssociation(collectionId);
        } catch(Exception ex) {
            // fall through
            throwNotFoundException(collectionId, MemberType.COLLECTION);
            return null; // to keep compiler happy.
        }
        if (association == null || !association.isOneToManyAssociation()) {
            throwNotFoundException(collectionId, MemberType.COLLECTION);
        }
        final OneToManyAssociation collection = (OneToManyAssociation) association;
        return memberThatIsVisibleForIntent(collection, MemberType.COLLECTION, intent, where);
    }
View Full Code Here

        final String identifier = oid.getIdentifier();
        final PreAndPostValues papv = auditEntry.getValue();
        final String preValue = papv.getPreString();
        final String postValue = papv.getPostString();
       
        final ObjectAssociation property = aap.getProperty();
        final String memberId = property.getIdentifier().toClassAndNameIdentityString();
        final String propertyId = property.getId();

        final String targetClass = CommandUtil.targetClassNameFor(adapter);
        final Bookmark target = new Bookmark(objectType, identifier);

        auditingService3.audit(getTransactionId(), targetClass, target, memberId, propertyId, preValue, postValue, user, timestamp);
View Full Code Here

        // work through all its fields
        final List<ObjectAssociation> fields = object.getSpecification().getAssociations(Contributed.EXCLUDED);

        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            final Object obj = field.get(object);

            final String id = field.getId();
            indent(s, level);

            if (field.isOneToManyAssociation()) {
                s.append(id + ": \n" + debugCollectionGraph((ObjectAdapter) obj, level + 1, recursiveElements));
            } else {
                if (recursiveElements.contains(obj)) {
                    s.append(id + ": " + obj + "*\n");
                } else {
View Full Code Here

            LOG.debug("includeField(Pl, Vec, Str):" + log("processing field", fieldName) + andlog("left", "" + names.size()));
        }

        // locate the field in the object's class
        final ObjectSpecification nos = object.getSpecification();
        ObjectAssociation field = null;
        try {
            // HACK: really want a ObjectSpecification.hasField method to
            // check first.
            field = nos.getAssociation(fieldName);
        } catch (final ObjectSpecificationException ex) {
            if (LOG.isInfoEnabled()) {
                LOG.info("includeField(Pl, Vec, Str): could not locate field, skipping");
            }
            return false;
        }

        // locate the corresponding XML element
        // (the corresponding XSD element will later be attached to xmlElement
        // as its userData)
        if (LOG.isDebugEnabled()) {
            LOG.debug("includeField(Pl, Vec, Str): locating corresponding XML element");
        }
        final Vector xmlFieldElements = elementsUnder(xmlElement, field.getId());
        if (xmlFieldElements.size() != 1) {
            if (LOG.isInfoEnabled()) {
                LOG.info("includeField(Pl, Vec, Str): could not locate " + log("field", field.getId()) + andlog("xmlFieldElements.size", "" + xmlFieldElements.size()));
            }
            return false;
        }
        final Element xmlFieldElement = (Element) xmlFieldElements.elementAt(0);

        if (names.size() == 0 && annotation != null) {
            // nothing left in the path, so we will apply the annotation now
            isisMetaModel.setAnnotationAttribute(xmlFieldElement, annotation);
        }

        final Place fieldPlace = new Place(object, xmlFieldElement);

        if (field instanceof OneToOneAssociation) {
            if (field.getSpecification().getAssociations(Contributed.EXCLUDED).size() == 0) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("includeField(Pl, Vec, Str): field is value; done");
                }
                return false;
            }
View Full Code Here

        final List<ObjectAssociation> fields = nos.getAssociations(Contributed.EXCLUDED);
        if (LOG.isDebugEnabled()) {
            LOG.debug("objectToElement(NO): processing fields");
        }
        eachField: for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            final String fieldName = field.getId();

            if (LOG.isDebugEnabled()) {
                LOG.debug("objectToElement(NO): " + log("field", fieldName));
            }

            // Skip field if we have seen the name already
            // This is a workaround for getLastActivity(). This method exists
            // in AbstractObjectAdapter, but is not (at some level) being picked
            // up
            // by the dot-net reflector as a property. On the other hand it does
            // exist as a field in the meta model (ObjectSpecification).
            //
            // Now, to re-expose the lastactivity field for .Net, a
            // deriveLastActivity()
            // has been added to BusinessObject. This caused another field of
            // the
            // same name, ultimately breaking the XSD.
            for (int j = 0; j < i; j++) {
                if (fieldName.equals(fields.get(i).getName())) {
                    LOG.debug("objectToElement(NO): " + log("field", fieldName) + " SKIPPED");
                    continue eachField;
                }
            }

            Element xmlFieldElement = getXmlDocument().createElementNS(schema.getUri(), // scoped
                                                                                        // by
                                                                                        // namespace
                    // of class of
                    // containing object
                    schema.getPrefix() + ":" + fieldName);

            Element xsdFieldElement = null;

            if (field.getSpecification().containsFacet(ValueFacet.class)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("objectToElement(NO): " + log("field", fieldName) + " is value");
                }

                final ObjectSpecification fieldNos = field.getSpecification();
                // skip fields of type XmlValue
                if (fieldNos == null) {
                    continue eachField;
                }
                if (fieldNos.getFullIdentifier() != null && fieldNos.getFullIdentifier().endsWith("XmlValue")) {
View Full Code Here

            final ResolveState stateWhilePersisting = ResolveState.UPDATING;
           
            adapter.changeState(stateWhilePersisting)

            for (int i = 0; i < associations.size(); i++) {
                final ObjectAssociation objectAssoc = associations.get(i);
                if (objectAssoc.isNotPersisted()) {
                    continue;
                }
                if (objectAssoc.isOneToManyAssociation()) {
                    final ObjectAdapter collection = objectAssoc.get(adapter);
                    if (collection == null) {
                        throw new ObjectPersistenceException("Collection " + objectAssoc.getName() + " does not exist in " + adapter.getSpecification().getFullIdentifier());
                    }
                    makePersistent(collection, toPersistObjectSet);
                } else {
                    final ObjectAdapter fieldValue = objectAssoc.get(adapter);
                    if (fieldValue == null) {
                        continue;
                    }
                    persist(fieldValue, toPersistObjectSet);
                }
View Full Code Here

        final ObjectAdapter object = instance;
        final ObjectSpecification nc = object.getSpecification();
        final List<ObjectAssociation> fields = nc.getAssociations(Contributed.EXCLUDED);

        for (int f = 0; f < fields.size(); f++) {
            final ObjectAssociation fld = fields.get(f);

            // are ignoring internal collections - these probably should be
            // considered
           
            // ignore non-persistent fields - there is no persisted field to
            // compare against
            if (fld.isNotPersisted()) {
                continue;
            }
            if (!fld.isOneToOneAssociation()) {
                continue;
            }

            // if pattern contains empty value then it matches anything
            if (fld.isEmpty(pattern)) {
                continue;
            }

            // find the object to match against, if any
            final ObjectAdapter reqd = fld.get(pattern);
            if (reqd == null) {
                continue;
            }

            // find the object; it's a bust if nothing
            final ObjectAdapter search = fld.get(object);
            if (search == null) {
                return false;
            }

            if (fld.getSpecification().isValue()) {
                // compare values directly
                if (!reqd.getObject().equals(search.getObject())) {
                    return false;
                }
               
View Full Code Here

            throw new FixtureException("no colon (:) in: " + line.trim());
        }
        final String name = line.substring(0, pos).trim();
        String data = line.substring(pos + 1).trim();
        try {
            final ObjectAssociation association = object.getSpecification().getAssociation(name);
            if (data.trim().length() == 0) {
                if (!association.isEmpty(object) && association instanceof OneToOneAssociation) {
                    ((OneToOneAssociation) association).set(object, null);
                }
            } else {
                if (association.isOneToManyAssociation()) {
                    final String[] ids = data.split(" ");
                    final ObjectAdapter[] elements = new ObjectAdapter[ids.length];
                    for (int i = 0; i < ids.length; i++) {
                        elements[i] = loaded.get(ids[i]);
                    }
                    final ObjectAdapter collection = association.get(object);
                    final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
                    facet.init(collection, elements);
                } else if (association.getSpecification().isParseable()) {
                    data = data.replaceAll("\\n", "\n");
                    final ParseableFacet facet = association.getSpecification().getFacet(ParseableFacet.class);
                    final ObjectAdapter value = facet.parseTextEntry(null, data, null);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                } else if (association.isOneToOneAssociation()) {
                    final ObjectAdapter value = loaded.get(data);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                }
            }
        } catch (final ObjectSpecificationException e) {
View Full Code Here

            if (fields.size() == 0) {
                debugBuilder.appendln("none");
            } else {
                for (int i = 0; i < fields.size(); i++) {

                    final ObjectAssociation field = fields.get(i);
                    debugBuilder.appendln((i + 1) + "." + field.getId() + "  (" + field.getClass().getName() + ")");

                    debugBuilder.indent();
                    final String description = field.getDescription();
                    if (description != null && !description.equals("")) {
                        debugBuilder.appendln("Description", description);
                    }
                    final String help = field.getHelp();
                    if (help != null && !help.equals("")) {
                        debugBuilder.appendln("Help", help.substring(0, Math.min(30, help.length())) + (help.length() > 30 ? "..." : ""));
                    }

                   
                    debugBuilder.appendln("ID", field.getIdentifier());
                    debugBuilder.appendln("Short ID", field.getId());
                    debugBuilder.appendln("Name", field.getName());
                    final String type = field.isOneToManyAssociation() ? "Collection" : field.isOneToOneAssociation() ? "Object" : "Unknown";
                    debugBuilder.appendln("Type", type);
                    final ObjectSpecification fieldSpec = field.getSpecification();
                    final boolean hasIdentity = !(fieldSpec.isParentedOrFreeCollection() || fieldSpec.isParented() || fieldSpec.isValue());
                    debugBuilder.appendln("Has identity", hasIdentity);
                    debugBuilder.appendln("Spec", fieldSpec.getFullIdentifier());

                    debugBuilder.appendln("Flags", (field.isAlwaysHidden() ? "" : "Visible ") + (field.isNotPersisted() ? "Not Persisted " : " ") + (field.isMandatory() ? "Mandatory " : ""));

                    final Class<? extends Facet>[] facets = field.getFacetTypes();
                    if (facets.length > 0) {
                        debugBuilder.appendln("Facets");
                        debugBuilder.indent();
                        boolean none = true;
                        for (final Class<? extends Facet> facet : facets) {
                            debugBuilder.appendln(field.getFacet(facet).toString());
                            none = false;
                        }
                        if (none) {
                            debugBuilder.appendln("none");
                        }
                        debugBuilder.unindent();
                    }

                    debugBuilder.appendln(field.debugData());

                    debugBuilder.unindent();
                }
            }
        } catch (final RuntimeException e) {
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.spec.feature.ObjectAssociation

Copyright © 2018 www.massapicom. 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.