Examples of FeatureModel


Examples of org.geomajas.layer.feature.FeatureModel

    InternalFeature newFeature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
    if (null == oldFeature) {
      // create new feature
      String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
      FeatureModel featureModel = layer.getFeatureModel();
      if (securityContext.isFeatureCreateAuthorized(layerId, newFeature)) {
        Object feature;
        if (newFeature.getId() == null) {
          feature = featureModel.newInstance();
        } else {
          feature = featureModel.newInstance(newFeature.getId());
        }
        context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, feature);
        context.put(PipelineCode.IS_CREATE_KEY, true);
      } else {
        throw new GeomajasSecurityException(ExceptionCode.FEATURE_CREATE_PROHIBITED, securityContext
View Full Code Here

Examples of org.geomajas.layer.feature.FeatureModel

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    InternalFeature newFeature = context.getOptional(PipelineCode.FEATURE_KEY, InternalFeature.class);
    Object feature = context.get(PipelineCode.FEATURE_DATA_OBJECT_KEY);
    String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    FeatureModel featureModel = layer.getFeatureModel();
    Boolean isCreateObject = context.getOptional(PipelineCode.IS_CREATE_KEY, Boolean.class);
    boolean isCreate  = false;
    if (null != isCreateObject && isCreateObject) {
      isCreate = true;
    }

    // Assure only writable attributes are set
    Map<String, Attribute> requestAttributes = newFeature.getAttributes();
    Map<String, Attribute> filteredAttributes = new HashMap<String, Attribute>();
    if (null != requestAttributes) {
      for (Map.Entry<String, Attribute> entry : requestAttributes.entrySet()) {
        String key = entry.getKey();
        if (securityContext.isAttributeWritable(layerId, newFeature, key)) {
          filteredAttributes.put(key, entry.getValue());
        }
      }
    }
    featureModel.setAttributes(feature, filteredAttributes);

    if (newFeature.getGeometry() != null) {
      featureModel.setGeometry(feature, newFeature.getGeometry());
    }

    Filter securityFilter;
    if (isCreate) {
      securityFilter = getSecurityFilter(layer, securityContext.getCreateAuthorizedArea(layerId));
    } else {
      securityFilter = getSecurityFilter(layer, securityContext.getUpdateAuthorizedArea(layerId));
    }
    if (securityFilter.evaluate(feature)) {
      context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, layer.saveOrUpdate(feature));
      if (isCreate) {
        newFeature.setId(featureModel.getId(feature));
      }
    } else {
      if (isCreate) {
        throw new GeomajasSecurityException(ExceptionCode.FEATURE_CREATE_PROHIBITED,
            securityContext.getUserId());
View Full Code Here

Examples of org.geomajas.layer.feature.FeatureModel

    private static Pattern ID_PATTERN = Pattern.compile("@(\\w+:)?id");

    protected static Pattern PROPERTY_PATTERN = Pattern.compile("((\\w+)(\\.|/))*(\\w+)");

    public boolean canHandle(Object object, String xpath, Class target) {
      FeatureModel fm = FeatureModelRegistry.getRegistry().lookup(object);
      return (fm != null);
    }
View Full Code Here

Examples of org.geomajas.layer.feature.FeatureModel

      FeatureModel fm = FeatureModelRegistry.getRegistry().lookup(object);
      return (fm != null);
    }

    public Object get(Object object, String xpath, Class target) throws IllegalArgumentException {
      FeatureModel fm = FeatureModelRegistry.getRegistry().lookup(object);
      if (null == fm) {
        throw new IllegalArgumentException("Objects of type " + object.getClass().getName() +
            " not registered in FeatureModelRegistry");
      }
      try {
        if (xpath.equals(fm.getGeometryAttributeName())) {
          return fm.getGeometry(object);
        } else if (ID_PATTERN.matcher(xpath).matches()) {
          return fm.getId(object);
        } else if (PROPERTY_PATTERN.matcher(xpath).matches()) {
          return fm.getAttribute(object, xpath).getValue();
        } else {
          return null;
        }
      } catch (LayerException e) {
        throw new IllegalArgumentException(e);
View Full Code Here

Examples of org.togglz.console.model.FeatureModel

    }

    public void add(Feature feature, FeatureMetaData metadata, FeatureState featureState) {

        // all features are shown in the ALL tab
        FeatureModel row = new FeatureModel(feature, metadata, strategies);
        row.populateFromFeatureState(featureState);
        allTab.add(row);

        for (FeatureGroup group : metadata.getGroups()) {

            String label = group.getLabel();
View Full Code Here

Examples of org.togglz.console.model.FeatureModel

            return;
        }

        FeatureMetaData metadata = featureManager.getMetaData(feature);
        List<ActivationStrategy> impls = featureManager.getActivationStrategies();
        FeatureModel featureModel = new FeatureModel(feature, metadata, impls);

        // GET requests for this feature
        if ("GET".equals(request.getMethod())) {

            FeatureState state = featureManager.getFeatureState(feature);
            featureModel.populateFromFeatureState(state);

            renderEditPage(event, featureModel);

        }

        // POST requests for this feature
        if ("POST".equals(request.getMethod())) {

            featureModel.restoreFromRequest(request);

            // no validation errors
            if (featureModel.isValid()) {

                FeatureState state = featureModel.toFeatureState();
                featureManager.setFeatureState(state);
                response.sendRedirect("index");

            }
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.