Examples of ExtendedPropertyDefinition


Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

                            if (newLanguageCodes.contains(NO_LOCALE)) {
                                ExtendedNodeType nodeType = NodeTypeRegistry.getInstance()
                                        .getNodeType(selector.getNodeTypeName());
                                boolean isFulltextIncludingMultilingualProperties = (propertyName == null && node instanceof FullTextSearch) ? isFulltextIncludingMultilingualProperties(
                                        nodeType, selector) : false;
                                ExtendedPropertyDefinition propDef = propertyName != null ? getPropertyDefinition(
                                        nodeType, selector, propertyName) : null;
                                if (propDef != null && propDef.isInternationalized()
                                        || isFulltextIncludingMultilingualProperties) {
                                    newLanguageCodes.remove(NO_LOCALE);
                                }
                            }

                            getModificationInfo().setModificationNecessary(true);
                        } else {
                            QueryObjectModelFactory qomFactory = getModificationInfo()
                                    .getQueryObjectModelFactory();
                            Set<String> newLanguageCodes = getNewLanguagesPerSelector().get(
                                    selector.getSelectorName());
                            if (newLanguageCodes != null) {
                                Constraint langConstraint = null;
                                for (String newLanguageCode : newLanguageCodes) {
                                    Constraint currentConstraint = NO_LOCALE
                                            .equals(newLanguageCode) ? qomFactory.not(qomFactory
                                            .propertyExistence(selector.getSelectorName(),
                                                    Constants.JCR_LANGUAGE))
                                            : qomFactory
                                                    .comparison(
                                                            qomFactory.propertyValue(
                                                                    selector.getSelectorName(),
                                                                    Constants.JCR_LANGUAGE),
                                                            QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
                                                            qomFactory.literal(getValueFactory()
                                                                    .createValue(newLanguageCode)));
                                    langConstraint = langConstraint == null ? currentConstraint
                                            : qomFactory.or(langConstraint, currentConstraint);
                                }
                                getModificationInfo().getNewConstraints().add(langConstraint);
                                if (languageCodes == null) {
                                    languageCodes = new HashSet<String>();
                                    getLanguagesPerSelector().put(selector.getSelectorName(),
                                            languageCodes);
                                }
                                languageCodes.addAll(newLanguageCodes);
                            }
                        }
                    }
                    if (node instanceof Column) {
                        String columnName = ((Column) node).getColumnName();
                        if (StringUtils.startsWith(columnName, "rep:facet(")
                                && !StringUtils.contains(columnName, "locale=")) {
                            ExtendedNodeType nodeType = NodeTypeRegistry.getInstance().getNodeType(
                                    selector.getNodeTypeName());
                            ExtendedPropertyDefinition propDef = propertyName != null ? getPropertyDefinition(
                                    nodeType, selector, propertyName) : null;
                            if (propDef != null && propDef.isInternationalized()) {
                                if (getModificationInfo().getMode() == CHECK_FOR_MODIFICATION_MODE) {
                                    getModificationInfo().setModificationNecessary(true);
                                } else {
                                    String facetOptions = columnName.substring("rep:facet("
                                            .length());
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

            return node;
        }

        private ExtendedPropertyDefinition getPropertyDefinition(ExtendedNodeType nodeType,
                Selector selector, String propertyName) throws RepositoryException {
            ExtendedPropertyDefinition propDef = null;

            if (!Constants.JAHIANT_TRANSLATION.equals(nodeType.getName())) {
                if (Constants.NT_BASE.equals(nodeType.getName())
                        || Constants.JAHIANT_CONTENT.equals(nodeType.getName())) {
                    Set<String> nodeTypes = getNodeTypesPerSelector().get(
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

                    child.addMixin(Constants.MIX_TITLE);
                } else if (attrName.equals("j:defaultCategory")
                        && !child.isNodeType(Constants.JAHIAMIX_CATEGORIZED)) {
                    child.addMixin(Constants.JAHIAMIX_CATEGORIZED);
                }
                ExtendedPropertyDefinition propDef;
                propDef = child.getApplicablePropertyDefinition(attrName);
                if (propDef == null) {
                    logger.error("Couldn't find definition for property " + attrName);
                    continue;
                }

                if (propDef.getRequiredType() == PropertyType.REFERENCE || propDef.getRequiredType() == ExtendedPropertyType.WEAKREFERENCE) {
                    if (attrValue.length() > 0) {
                        String[] values = attrValue.split(" ");
                        for (String value : values) {
                            if (!StringUtils.isEmpty(value)) {
                                for (Map.Entry<String, String> entry : pathMapping.entrySet()) {
                                    if (value.startsWith(entry.getKey())) {
                                        value = entry.getValue() + StringUtils.substringAfter(value, entry.getKey());
                                        break;
                                    }
                                }
                                if (attrName.equals("j:defaultCategory") && value.startsWith("/root")) {
                                    // Map categories from legacy imports
                                    value = JCRContentUtils.getSystemSitePath() + "/categories" + StringUtils.substringAfter(value, "/root");
                                }
                                if (!references.containsKey(value)) {
                                    references.put(value, new ArrayList<String>());
                                }
                                references.get(value).add(child.getIdentifier() + "/" + attrName);
                            }
                        }
                    }
                } else {
                    if (propDef.isMultiple()) {
                        String[] s = "".equals(attrValue) ? new String[0] : attrValue.split(" ");
                        Value[] v = new Value[s.length];
                        for (int j = 0; j < s.length; j++) {
                            v[j] = child.getRealNode().getSession().getValueFactory().createValue(s[j]);
                        }
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

                // case of property
                if (item instanceof Property) {
                    Property property = (Property) item;
                    PropertyDefinition propertyDefintion = property.getDefinition();
                    if (propertyDefintion != null && propertyDefintion instanceof ExtendedPropertyDefinition) {
                        ExtendedPropertyDefinition itemDef = (ExtendedPropertyDefinition) propertyDefintion;
                        return itemDef.getLabel(locale,nodeTypeForSearchingLabel);
                    } else {
                        logger.error("PropertyDefinition doesn't implement 'org.jahia.services.content.nodetypes.ExtendedPropertyDefinition'");
                    }
                }
                // case of PropertyDefinition
                else if (item instanceof PropertyDefinition) {
                    if (item instanceof ExtendedPropertyDefinition) {
                        ExtendedPropertyDefinition itemDef = (ExtendedPropertyDefinition) item;
                        return itemDef.getLabel(locale,nodeTypeForSearchingLabel);
                    } else {
                        logger.error("PropertyDefinition doesn't implement 'org.jahia.services.content.nodetypes.ExtendedPropertyDefinition'");
                    }
                }
                // case of node type
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

        return getPropertyDefinition(NodeTypeRegistry.getInstance().getNodeType(
                        nodeType), property);
    }

    public static int getPropertyDefSelector(ItemDefinition itemDef) {
        ExtendedPropertyDefinition propDefExtension = null;
        if (itemDef instanceof PropertyDefinition) {
            propDefExtension = getPropertyDefExtension((PropertyDefinition) itemDef);
        }

        return propDefExtension != null ? propDefExtension.getSelector() : 0;
    }
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

            }
            JCRNodeWrapper ref = n.addNode("j:referenceInField_"+pName+"_"+id, "jnt:referenceInField");
            ref.setProperty("j:fieldName",pName);
            ref.setProperty("j:reference", value);
        } else {
            final ExtendedPropertyDefinition propertyDefinition = n.getApplicablePropertyDefinition(pName);
            if (propertyDefinition == null) {
                throw new ConstraintViolationException("Couldn't find definition for property "+pName );
            }
            if (propertyDefinition.isMultiple()) {
                Value[] newValues;
                if (n.hasProperty(pName)) {
                    final Value[] oldValues = n.getProperty(pName).getValues();
                    newValues = new Value[oldValues.length+1];
                    for (Value oldValue : oldValues) {
                        // value already set
                        if (oldValue.getString().equals(value)) {
                            return;
                        }
                    }
                    System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
                } else {
                    newValues = new Value[1];
                }
                newValues[newValues.length-1] =  session.getValueFactory().createValue(value, propertyDefinition.getRequiredType() );
                if (!n.hasProperty(pName) || !Arrays.equals(newValues, n.getProperty(pName).getValues())) {
                    session.checkout(n);
                    n.setProperty(pName, newValues);
                }
            } else {
                if (!n.hasProperty(pName) || !value.equals(n.getProperty(pName).getString())) {
                    session.checkout(n);
                    n.setProperty(pName, session.getValueFactory().createValue(value, propertyDefinition.getRequiredType()));
                }
            }
        }
    }
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

        parent = checkoutNode(parent);
        if (!StringUtils.isEmpty(mixinType) && !parent.isNodeType(mixinType)) {
            parent.addMixin(mixinType);
        }

        ExtendedPropertyDefinition propertyDefinition = null;
        propertyDefinition = parent.getApplicablePropertyDefinition(propertyName);
        if (propertyDefinition == null) {
            return false;

        }
        if (propertyDefinition.isProtected()) {
            // System.out.println("protected : " + propertyName);
            return false;
        }
        Node n = parent;

        // System.out.println("setting " + propertyName);

        if (value != null && value.length() != 0 && !value.equals("<empty>")) {
            switch (propertyDefinition.getRequiredType()) {
                case PropertyType.DATE:
                    GregorianCalendar cal = new GregorianCalendar();
                    try {
                        DateFormat df = new SimpleDateFormat(ImportExportService.DATE_FORMAT);
                        Date d = df.parse(value);
                        cal.setTime(d);
                        n.setProperty(propertyName, cal);
                    } catch (java.text.ParseException e) {
                        e.printStackTrace();
                    }
                    break;

                default:
                    switch (propertyDefinition.getSelector()) {
                        case SelectorType.CATEGORY: {
                            String[] cats = value.split(",");
                            List<Value> values = new ArrayList<Value>();
                            for (int i = 0; i < cats.length; i++) {
                                String cat = cats[i];
                                Query q = session.getWorkspace().getQueryManager().createQuery("select * from [jnt:category] as cat where NAME(cat) = '"+cat+"'", Query.JCR_SQL2);
                                NodeIterator ni = q.execute().getNodes();
                                if (ni.hasNext()) {
                                    values.add(session.getValueFactory().createValue(ni.nextNode()));
                                }
                            }
                            n.setProperty(propertyName, values.toArray(new Value[values.size()]));
                            break;
                        }
                        case SelectorType.RICHTEXT: {
                            n.setProperty(propertyName, value);
                            break;
                        }
                        default: {
                            String[] vcs = propertyDefinition.getValueConstraints();
                            List<String> constraints = Arrays.asList(vcs);
                            if (!propertyDefinition.isMultiple()) {
                                if (value.startsWith("<jahia-resource")) {
                                    value = ResourceBundleMarker.parseMarkerValue(value)
                                            .getResourceKey();
                                    if (value.startsWith(propertyDefinition.getResourceBundleKey())) {
                                        value = value.substring(propertyDefinition
                                                .getResourceBundleKey().length() + 1);
                                    }
                                }
                                value = baseType != null && mapping != null ? mapping.getMappedPropertyValue(baseType,
                                        localName, value) : value;
                                if (constraints.isEmpty() || constraints.contains(value)) {
                                    try {
                                        n.setProperty(propertyName, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            } else {
                                String[] strings = value.split("\\$\\$\\$");
                                List<Value> values = new ArrayList<Value>();
                                for (int i = 0; i < strings.length; i++) {
                                    String string = strings[i];

                                    if (string.startsWith("<jahia-resource")) {
                                        string = ResourceBundleMarker.parseMarkerValue(string)
                                                .getResourceKey();
                                        if (string.startsWith(propertyDefinition
                                                .getResourceBundleKey())) {
                                            string = string.substring(propertyDefinition
                                                    .getResourceBundleKey().length() + 1);
                                        }
                                    }
                                    value = baseType != null ? mapping.getMappedPropertyValue(
                                            baseType, localName, value) : value;
                                    if (constraints.isEmpty() || constraints.contains(value)) {
                                        values.add(new ValueImpl(string, propertyDefinition
                                                .getRequiredType()));
                                    }
                                }
                                ;
                                n.setProperty(propertyName,
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

        if (null != facetFs) {
            for (String f : facetFs) {
                try {
                    String fieldName = StringUtils.substringBeforeLast(f, PROPNAME_INDEX_SEPARATOR);
                    String locale = params.getFieldParam(f, "facet.locale");
                    ExtendedPropertyDefinition epd = NodeTypeRegistry.getInstance().getNodeType(
                            params.get("f." + f + ".facet.nodetype")).getPropertyDefinition(
                            fieldName);
                    String fieldNameInIndex = getFieldNameInIndex(fieldName, epd, locale);
                    res.add(StringUtils.substringBeforeLast(f, PROPNAME_INDEX_SEPARATOR)
                            + PROPNAME_INDEX_SEPARATOR + fieldNameInIndex,
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

            return resOuter;

        for (String f : fields) {
            final NamedList<Object> resInner = new SimpleOrderedMap<Object>();
            String fieldName = StringUtils.substringBeforeLast(f, PROPNAME_INDEX_SEPARATOR);           
            ExtendedPropertyDefinition epd = NodeTypeRegistry.getInstance().getNodeType(params.get("f."+f+".facet.nodetype")).getPropertyDefinition(fieldName);
            String fieldNameInIndex = getFieldNameInIndex(fieldName, epd, params.getFieldParam(f,
                    "facet.locale"));
           
            resOuter.add(fieldName + PROPNAME_INDEX_SEPARATOR + fieldNameInIndex, resInner);
           
            if (!(epd.getRequiredType() == PropertyType.DATE)) {
                throw new JahiaException("Can not date facet on a field which is not a DateField: "
                        + f, "Can not date facet on a field which is not a DateField: " + f,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY);
            }
            Integer mincount = params.getFieldInt(f, FacetParams.FACET_MINCOUNT);
View Full Code Here

Examples of org.jahia.services.content.nodetypes.ExtendedPropertyDefinition

                return res;
            }

            if (getPropertiesIterator().hasNext()) {
                Property property = getPropertiesIterator().nextProperty();
                ExtendedPropertyDefinition epd = node.getApplicablePropertyDefinition(property.getName());
                return new JCRPropertyWrapperImpl(node, property, node.getSession(), node.getProvider(), epd);
            } else {
                do {
                    Property property = getI18NPropertyIterator().nextProperty();
                    final String name = property.getName();
                    final ExtendedPropertyDefinition def = node.getApplicablePropertyDefinition(name);
                    if (def != null && def.isInternationalized()) {
                        return new JCRPropertyWrapperImpl(node, property, node.getSession(), node.getProvider(), def, name);
                    }
                } while (true);
            }
        } catch (ConstraintViolationException e) {
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.