Package org.auraframework.def

Examples of org.auraframework.def.AttributeDef


                    gvp.validate(stem);
                }
            } else if (vpt == ValueProviderType.VIEW) {
                if (e.getStem() != null) { // checks for private attributes used in expressions ..
                    String stem = e.getStem().toString();
                    AttributeDef attr = getAttributeDef(stem);
                    if ((attr != null) && (attr.getVisibility() == Visibility.PRIVATE)
                            && (!this.attributeDefs.values().contains(attr))) {
                        throw new InvalidDefinitionException(String.format(
                                "Expression %s refers to a private attribute '%s' ", e, attr), e.getLocation());
                    }
                }
View Full Code Here


        DefDescriptor<?> desc = def.getDescriptor();

        String namespace;
        String target;
        if (def instanceof AttributeDef) {
            AttributeDef attributeDef = (AttributeDef) def;
            DefDescriptor<? extends RootDefinition> parentDescriptor = attributeDef.getParentDescriptor();
            namespace = parentDescriptor.getNamespace();
            target = String.format("%s:%s.%s", namespace, parentDescriptor.getName(), desc.getName());
        } else {
            namespace = desc.getNamespace();
            target = String.format("%s:%s", namespace, desc.getName());
View Full Code Here

            throw new DefinitionNotFoundException(cmpDesc, getLocation());
        }

        if (!attributeDesignDefs.isEmpty()) {
            for (AttributeDesignDef attrDesignDef : attributeDesignDefs.values()) {
                AttributeDef attr = cmp.getAttributeDef(attrDesignDef.getName());
                if (attr == null) {
                    throw new DefinitionNotFoundException(DefDescriptorImpl.getInstance(attrDesignDef.getName(),
                            AttributeDef.class));
                }
            }
View Full Code Here

    private void set(AttributeDefRef attributeDefRef) throws QuickFixException {
        RootDefinition def = rootDefDescriptor.getDef();
        Map<DefDescriptor<AttributeDef>, AttributeDef> attributeDefs = def.getAttributeDefs();

        AttributeDef attributeDef = attributeDefs.get(attributeDefRef.getDescriptor());
        // setAndValidateAttribute should be merged with creating the
        // AttributeImpl here
        AttributeImpl attribute;

        if (attributeDef == null) {
            Map<String, RegisterEventDef> events = def.getRegisterEventDefs();
            if (events.containsKey(attributeDefRef.getDescriptor().getName())) {
                EventHandlerImpl eh = new EventHandlerImpl(attributeDefRef.getDescriptor().getName());
                Object o = attributeDefRef.getValue();
                if (!(o instanceof PropertyReference)) {
                    // FIXME: where are we?
                    throw new InvalidDefinitionException(String.format("%s no can haz %s", eh.getName(), o),
                            SUPER_PASSTHROUGH);
                }
                eh.setActionExpression((PropertyReference) o);
                set(eh);
                return;
            } else {
                // FIXME: where are we?
                throw new AttributeNotFoundException(rootDefDescriptor, attributeDefRef.getName(), SUPER_PASSTHROUGH);
            }
        } else {
            attribute = new AttributeImpl(attributeDef.getDescriptor());
        }

        Object value = attributeDefRef.getValue();
        InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();
        iStack.markParent(parent);
        iStack.setAttributeName(attributeDef.getDescriptor().toString());
        value = attributeDef.getTypeDef().initialize(value, valueProvider);
        iStack.clearAttributeName(attributeDef.getDescriptor().toString());
        iStack.clearParent(parent);
        attribute.setValue(value);

        set(attribute);
    }
View Full Code Here

        return null;
    }

    private void setExpression(DefDescriptor<AttributeDef> desc, Object value) throws QuickFixException {
        RootDefinition rd = rootDefDescriptor.getDef();
        AttributeDef ad = rd.getAttributeDefs().get(desc);
        if (ad == null) {
            // this location isn't even close to right...
            throw new InvalidDefinitionException(String.format("Attribute %s not defined on %s", desc.getName(),
                    rootDefDescriptor.getName()), rd.getLocation());
        }
View Full Code Here

            value = ((Expression) value).evaluate(valueProvider);
        }
        if (value instanceof ValueProvider && stem != null) {
            value = ((ValueProvider) value).getValue(stem);
        } else if (stem != null) {
            AttributeDef attributeDef = rootDefDescriptor.getDef().getAttributeDef(expr.getRoot());
            value = attributeDef.getTypeDef().wrap(value);
            if (value instanceof ValueProvider) {
                value = ((ValueProvider) value).getValue(stem);
            }
        }
        if (value instanceof Wrapper) {
View Full Code Here

                json.writeMapKey("values");
                json.writeMapBegin();

                for (Attribute attribute : attributes.values()) {
                    String name = attribute.getName();
                    AttributeDef attributeDef = def.getAttributeDef(name);
                    if (attributeDef == null) {
                        throw new AttributeNotFoundException(rootDefDescriptor, name, def.getLocation());
                    }

                    if (attributeDef.getSerializeTo() == AttributeDef.SerializeToType.BOTH) {
                        TypeDef typeDef = attributeDef.getTypeDef();
                        if ((valueProvider == null && !((typeDef instanceof ComponentArrayTypeDef) || (typeDef instanceof ComponentTypeDef)))
                                || attribute.isDirty()) {
                            json.writeMapEntry(name, attribute.getValue());
                        }
                    }
View Full Code Here

        }
        //
        // Walk all attributes, pushing the reinitialize model in to those as well.
        //
        for (Map.Entry<DefDescriptor<AttributeDef>, AttributeDef> foo : def.getAttributeDefs().entrySet()) {
            AttributeDef attr = foo.getValue();
            DefDescriptor<?> typeDesc;
            if (attr instanceof AttributeDefImpl) {
                AttributeDefImpl attri = (AttributeDefImpl) attr;
                typeDesc = attri.getTypeDesc();
            } else {
                // bad.
                typeDesc = attr.getTypeDef().getDescriptor();
            }
            if (componentArrType.equals(typeDesc)) {
                Object val = getAttributes().getValue(foo.getKey().getName());
                if (val instanceof List) {
                    @SuppressWarnings("unchecked")
View Full Code Here

    public void testValueRequired() throws Exception {
        List<String> failures = Lists.newLinkedList();
        Aura.getContextService().startContext(Mode.PROD, Format.HTML, Authentication.AUTHENTICATED);
        for (ComponentDef def : getUiOutputComponents()) {
            String name = def.getName();
            AttributeDef value = def.getAttributeDef("value");
            if (value == null || !value.isRequired()) {
                failures.add(name);
            }
        }
        if (!failures.isEmpty()) {
            fail("The following ui:output* components should have a required 'value' attributef: " + failures);
View Full Code Here

        Map<DefDescriptor<AttributeDef>, AttributeDef> atts = rootDef.getAttributeDefs();
        Map<String, RegisterEventDef> registeredEvents = rootDef.getRegisterEventDefs();
        MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
        for (Entry<DefDescriptor<AttributeDef>, AttributeDefRef> entry : getAttributeValues().entrySet()) {
            DefDescriptor<AttributeDef> attributeDefDesc = entry.getKey();
            AttributeDef attributeDef = atts.get(attributeDefDesc);
            if (attributeDef == null) {
                // didn't find an attribute by that name, check if there's an
                // event
                RegisterEventDef registeredEvent = registeredEvents.get(attributeDefDesc.getName());
                if (registeredEvent == null) {
                    throw new AttributeNotFoundException(rootDef.getDescriptor(), attributeDefDesc.getName(),
                            getLocation());
                }
               
              registry.assertAccess(referencingDesc, registeredEvent);
            } else {
              if (referencingDesc != null) {
                // Validate that the referencing component has access to the attribute
                registry.assertAccess(referencingDesc, attributeDef);
              }
             
                // so it was an attribute, make sure to parse it
                entry.getValue().parseValue(attributeDef.getTypeDef());
            }
           
            entry.getValue().validateReferences();
            // heres where some type validation would go
        }
View Full Code Here

TOP

Related Classes of org.auraframework.def.AttributeDef

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.