You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2016/03/17 02:13:14 UTC
[10/23] incubator-openaz git commit: Revert "Ported original att
source to openaz"
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
deleted file mode 100644
index c1568b9..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import org.apache.openaz.xacml.admin.jpa.Attribute;
-import org.apache.openaz.xacml.admin.jpa.Category;
-import org.apache.openaz.xacml.admin.jpa.Datatype;
-import org.apache.openaz.xacml.admin.util.JPAUtils;
-import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
-import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
-import org.apache.openaz.xacml.api.XACML3;
-import com.vaadin.addon.jpacontainer.JPAContainer;
-import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-
-public class AttributeSimpleCreatorComponent extends CustomComponent implements AttributeChangedEventNotifier {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private HorizontalLayout horizontalLayout_1;
- @AutoGenerated
- private Table tableDatatype;
- @AutoGenerated
- private Table tableCategory;
- @AutoGenerated
- private TextField textFieldContextPath;
- @AutoGenerated
- private TextField textFieldAttributeId;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final AttributeSimpleCreatorComponent self = this;
- private final Datatype datatype;
- private final Attribute attribute;
- private final BasicNotifier notifier = new BasicNotifier();
- private static final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
- private static final JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
- static {
- categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
- datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
- categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
- datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
- }
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public AttributeSimpleCreatorComponent(Datatype datatype, Attribute initialAttribute) {
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // Save
- //
- this.datatype = datatype;
- this.attribute = initialAttribute;
- //
- // Initialize GUI
- //
- this.initializeCategories();
- this.initializeDatatypes();
- this.initializeAttributeId();
- //
- // Focus
- //
- this.textFieldAttributeId.focus();
- }
-
- private void initializeCategories() {
- //
- // Remove any filters
- //
- AttributeSimpleCreatorComponent.categories.removeAllContainerFilters();
- //
- // Initialize data source & GUI properties
- //
- this.tableCategory.setContainerDataSource(AttributeSimpleCreatorComponent.categories);
- this.tableCategory.setVisibleColumns(new Object[] {"xacmlId"});
- this.tableCategory.setColumnHeaders(new String[] {"XACML ID"});
- this.tableCategory.setImmediate(true);
- this.tableCategory.setNullSelectionAllowed(false);
- this.tableCategory.setPageLength(10);
- this.tableCategory.setSelectable(true);
- //
- // Default selection
- //
- Category defaultCategory;
- if (this.attribute == null || this.attribute.getCategoryBean() == null || this.attribute.getCategoryBean().getIdentifer() == null) {
- defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
- assert defaultCategory != null;
- } else {
- defaultCategory = JPAUtils.findCategory(this.attribute.getCategoryBean().getIdentifer());
- }
- if (defaultCategory != null) {
- this.tableCategory.select(defaultCategory.getId());
- }
- //
- // Respond to changes
- //
- this.tableCategory.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- private void initializeDatatypes() {
- //
- // Remove any filters
- //
- AttributeSimpleCreatorComponent.datatypes.removeAllContainerFilters();
- //
- // Initialize data source & GUI properties
- //
- this.tableDatatype.setContainerDataSource(AttributeSimpleCreatorComponent.datatypes);
- this.tableDatatype.setVisibleColumns(new Object[] {"xacmlId", "shortName"});
- this.tableDatatype.setColumnHeaders(new String[] {"Data Type ID", "Data Type"});
- this.tableDatatype.setNullSelectionAllowed(false);
- this.tableDatatype.setImmediate(true);
- this.tableDatatype.setPageLength(10);
- //
- // Are we restricted to a certain datatype?
- //
- if (this.datatype != null) {
- //
- // Datatype restricted
- //
- this.tableDatatype.select(this.datatype.getId());
- this.tableDatatype.setEnabled(false);
- return;
- }
- this.tableDatatype.setSelectable(true);
- //
- // Do we have a default value?
- //
- Datatype defaultDatatype;
- if (this.attribute != null && this.attribute.getDatatypeBean() != null) {
- defaultDatatype = this.attribute.getDatatypeBean();
- } else {
- defaultDatatype = JPAUtils.findDatatype(XACML3.ID_DATATYPE_STRING);
- }
- if (defaultDatatype != null) {
- this.tableDatatype.select(defaultDatatype.getId());
- }
- //
- // Respond to changes
- //
- this.tableDatatype.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- private void initializeAttributeId() {
- this.textFieldAttributeId.setImmediate(true);
- this.textFieldAttributeId.setNullRepresentation("");
- if (this.attribute == null) {
- this.textFieldAttributeId.setValue(XacmlAdminUI.getDomain());
- } else {
- //
- // Set the ID
- //
- this.textFieldAttributeId.setValue(this.attribute.getXacmlId());
- //
- // Is it an attribute selector?
- //
- if (this.attribute.isDesignator()) {
- this.textFieldContextPath.setVisible(false);
- this.textFieldContextPath.setRequired(false);
- } else {
- this.textFieldAttributeId.setCaption("Context Selector Id");
- this.textFieldAttributeId.setRequired(false);
- this.textFieldContextPath.setVisible(true);
- this.textFieldContextPath.setValue(this.attribute.getSelectorPath());
- this.textFieldContextPath.setRequired(true);
- this.textFieldContextPath.setRequiredError("You must have a context path for a selector.");
- this.textFieldContextPath.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
- }
- //
- // Respond to changes
- //
- this.textFieldAttributeId.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- @Override
- public Attribute getAttribute() {
- try {
- this.textFieldAttributeId.commit();
- } catch (Exception e) { //NOPMD
- // TODO - Handle, Log or NOPMD
- // TODO - Will vaadin display error?
- }
- Attribute attribute = new Attribute(this.textFieldAttributeId.getValue());
- attribute.setSelectorPath(this.textFieldContextPath.getValue());
- Object categoryId = this.tableCategory.getValue();
- if (categoryId != null) {
- attribute.setCategoryBean(AttributeSimpleCreatorComponent.categories.getItem(categoryId).getEntity());
- }
- if (this.datatype != null) {
- attribute.setDatatypeBean(this.datatype);
- } else {
- Object datatypeId = this.tableDatatype.getValue();
- if (datatypeId == null) {
- return null;
- }
- attribute.setDatatypeBean(AttributeSimpleCreatorComponent.datatypes.getItem(datatypeId).getEntity());
- }
- return attribute;
- }
-
- @Override
- public boolean addListener(AttributeChangedEventListener listener) {
- return this.notifier.addListener(listener);
- }
-
- @Override
- public boolean removeListener(AttributeChangedEventListener listener) {
- return this.notifier.removeListener(listener);
- }
-
- @Override
- public void commit() {
- try {
- this.textFieldAttributeId.commit();
- this.textFieldContextPath.commit();
- this.tableCategory.commit();
- this.tableDatatype.commit();
- } catch (Exception e) { //NOPMD
- // TODO - Handle, Log or NOPMD
- // TODO - Will vaadin display error?
- }
- }
-
- @Override
- public void fireAttributeChanged(Attribute attribute) {
- this.notifier.fireAttributeChanged(attribute);
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldAttributeId
- textFieldAttributeId = new TextField();
- textFieldAttributeId.setCaption("Attribute Id");
- textFieldAttributeId.setImmediate(false);
- textFieldAttributeId.setWidth("100.0%");
- textFieldAttributeId.setHeight("-1px");
- textFieldAttributeId.setInvalidAllowed(false);
- textFieldAttributeId.setRequired(true);
- mainLayout.addComponent(textFieldAttributeId);
- mainLayout.setExpandRatio(textFieldAttributeId, 1.0f);
-
- // textFieldContextPath
- textFieldContextPath = new TextField();
- textFieldContextPath.setCaption("Context Path");
- textFieldContextPath.setImmediate(false);
- textFieldContextPath.setDescription("The Selector's Context Path.");
- textFieldContextPath.setWidth("100.0%");
- textFieldContextPath.setHeight("-1px");
- textFieldContextPath
- .setInputPrompt("eg. md:record/md:patient/md:patient-number/text()");
- mainLayout.addComponent(textFieldContextPath);
- mainLayout.setExpandRatio(textFieldContextPath, 1.0f);
-
- // horizontalLayout_1
- horizontalLayout_1 = buildHorizontalLayout_1();
- mainLayout.addComponent(horizontalLayout_1);
- mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
-
- return mainLayout;
- }
-
- @AutoGenerated
- private HorizontalLayout buildHorizontalLayout_1() {
- // common part: create layout
- horizontalLayout_1 = new HorizontalLayout();
- horizontalLayout_1.setImmediate(false);
- horizontalLayout_1.setWidth("-1px");
- horizontalLayout_1.setHeight("-1px");
- horizontalLayout_1.setMargin(false);
- horizontalLayout_1.setSpacing(true);
-
- // tableCategory
- tableCategory = new Table();
- tableCategory.setCaption("Choose Category");
- tableCategory.setImmediate(false);
- tableCategory.setWidth("-1px");
- tableCategory.setHeight("-1px");
- tableCategory.setInvalidAllowed(false);
- tableCategory.setRequired(true);
- horizontalLayout_1.addComponent(tableCategory);
-
- // tableDatatype
- tableDatatype = new Table();
- tableDatatype.setCaption("Choose Data Type");
- tableDatatype.setImmediate(false);
- tableDatatype.setWidth("-1px");
- tableDatatype.setHeight("-1px");
- tableDatatype.setInvalidAllowed(false);
- tableDatatype.setRequired(true);
- horizontalLayout_1.addComponent(tableDatatype);
-
- return horizontalLayout_1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
deleted file mode 100644
index a3fded5..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import org.apache.openaz.xacml.admin.jpa.Attribute;
-import org.apache.openaz.xacml.admin.jpa.Category;
-import org.apache.openaz.xacml.admin.jpa.Datatype;
-import org.apache.openaz.xacml.admin.util.JPAUtils;
-import org.apache.openaz.xacml.admin.util.XACMLConstants;
-import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
-import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
-import org.apache.openaz.xacml.api.Identifier;
-import org.apache.openaz.xacml.api.XACML3;
-import com.vaadin.addon.jpacontainer.JPAContainer;
-import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-
-public class AttributeStandardSelectorComponent extends CustomComponent implements AttributeChangedEventNotifier {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private HorizontalLayout horizontalLayout_2;
- @AutoGenerated
- private Table tableDatatypes;
- @AutoGenerated
- private Table tableAttributes;
- @AutoGenerated
- private ComboBox comboBoxCategories;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public class AttributeBean implements Serializable {
- private static final long serialVersionUID = 1L;
- private Identifier attributeId;
- private Identifier categoryId;
-
- public AttributeBean(Identifier category, Identifier id) {
- this.categoryId = category;
- this.attributeId = id;
- }
- public Identifier getAttributeId() {
- return attributeId;
- }
- public void setAttributeId(Identifier attributeId) {
- this.attributeId = attributeId;
- }
- public Identifier getCategoryId() {
- return categoryId;
- }
- public void setCategoryId(Identifier categoryId) {
- this.categoryId = categoryId;
- }
- @Override
- public String toString() {
- return this.attributeId.stringValue();
- }
-
- }
- private final AttributeStandardSelectorComponent self = this;
- private final Datatype datatype;
- private final Attribute attribute;
- private final BasicNotifier notifier = new BasicNotifier();
- private static final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
- private static final JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
- static {
- categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
- datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
- categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
- datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
- }
- private BeanItemContainer<AttributeBean> container = new BeanItemContainer<AttributeBean>(AttributeBean.class);
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public AttributeStandardSelectorComponent(Datatype datatype, Attribute initialAttribute) {
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // Save
- //
- this.datatype = datatype;
- this.attribute = initialAttribute;
- //
- // Initialize GUI
- //
- this.initializeCategories();
- this.initializeAttributes();
- this.initializeDatatypes();
- //
- // Initialize focus
- //
- this.tableAttributes.focus();
- }
-
- private void initializeCategories() {
- //
- // Remove any filters
- //
- AttributeStandardSelectorComponent.categories.removeAllContainerFilters();
- //
- // Initialize data source & GUI properties
- //
- this.comboBoxCategories.setContainerDataSource(AttributeStandardSelectorComponent.categories);
- this.comboBoxCategories.setItemCaptionMode(ItemCaptionMode.PROPERTY);
- this.comboBoxCategories.setItemCaptionPropertyId("xacmlId");
- this.comboBoxCategories.setImmediate(true);
- this.comboBoxCategories.setNullSelectionAllowed(false);
- //
- // Set default selection
- //
- Category defaultCategory;
- if (this.attribute == null || this.attribute.getCategoryBean() == null) {
- defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
- } else {
- defaultCategory = this.attribute.getCategoryBean();
- }
- if (defaultCategory != null) {
- this.comboBoxCategories.select(defaultCategory.getId());
- }
- //
- // Respond to events
- //
- this.comboBoxCategories.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.setupAttributeIDs();
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- private void initializeAttributes() {
- //
- // Initialize GUI properties
- //
- this.tableAttributes.setImmediate(true);
- this.tableAttributes.setNullSelectionAllowed(false);
- this.tableAttributes.setPageLength(10);
- //
- // Setup
- //
- this.tableAttributes.setContainerDataSource(this.container);
- this.tableAttributes.setVisibleColumns(new Object[] {"attributeId"});
- this.tableAttributes.setColumnHeaders(new String[] {"Attribute Id"});
- this.tableAttributes.setSelectable(true);
- this.setupAttributeIDs();
- //
- // Respond
- //
- this.tableAttributes.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- private void initializeDatatypes() {
- //
- // Remove any filters
- //
- AttributeStandardSelectorComponent.datatypes.removeAllContainerFilters();
- //
- // Initialize data source & GUI properties
- //
- this.tableDatatypes.setContainerDataSource(AttributeStandardSelectorComponent.datatypes);
- this.tableDatatypes.setVisibleColumns(new Object[] {"shortName", "xacmlId"});
- this.tableDatatypes.setColumnHeaders(new String[] {"Short Name", "XACML Data Type ID"});
- this.tableDatatypes.setImmediate(true);
- this.tableDatatypes.setNullSelectionAllowed(false);
- this.tableDatatypes.setPageLength(10);
- //
- // Are we restricted to a certain datatype?
- //
- if (this.datatype != null) {
- //
- // Datatype restricted
- //
- this.tableDatatypes.select(this.datatype.getId());
- this.tableDatatypes.setEnabled(false);
- return;
- }
- this.tableDatatypes.setSelectable(true);
- //
- // Select a default
- //
- Datatype defaultDatatype;
- if (this.attribute == null || this.attribute.getDatatypeBean() == null) {
- defaultDatatype = JPAUtils.findDatatype(XACML3.ID_DATATYPE_STRING);
- } else {
- defaultDatatype = this.attribute.getDatatypeBean();
- }
- if (defaultDatatype != null) {
- this.tableDatatypes.select(defaultDatatype.getId());
- }
- //
- // Respond to events
- //
- this.tableDatatypes.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.fireAttributeChanged(self.getAttribute());
- }
- });
- }
-
- private void setupAttributeIDs() {
- //
- // Get the current selection (should NOT be null)
- //
- Object id = this.comboBoxCategories.getValue();
- Category category = AttributeStandardSelectorComponent.categories.getItem(id).getEntity();
- Set<Identifier> attributeIDs = null;
- if (category.isStandard()) {
- //
- // Get the subset of attribute ID's specific to this standard
- // category.
- //
- attributeIDs = XACMLConstants.MAP_STANDARD_CATEGORIES.get(category.getIdentifer());
- }
- if (attributeIDs == null) {
- //
- // A custom category, there are no default attribute IDs
- // that we can determine.
- //
- attributeIDs = XACMLConstants.STANDARD_ATTRIBUTES;
- }
- //
- // Reset attribute IDs. Based on the category, add only acceptable
- // attribute ID's for the category.
- //
- Object defaultBean = null;
- this.tableAttributes.removeAllItems();
- for (Identifier attributeId : attributeIDs) {
- BeanItem<AttributeBean> newItem = this.container.addItem(new AttributeBean(category.getIdentifer(), attributeId));
- if (this.attribute == null) {
- if (attributeId.equals(XACML3.ID_SUBJECT_SUBJECT_ID) ||
- attributeId.equals(XACML3.ID_ACTION_ACTION_ID) ||
- attributeId.equals(XACML3.ID_RESOURCE_RESOURCE_ID) ||
- attributeId.equals(XACML3.ID_ENVIRONMENT_CURRENT_DATE)) {
- defaultBean = newItem.getBean();
- }
- } else {
- if (newItem.getBean().getAttributeId().stringValue().equals(this.attribute.getXacmlId())) {
- defaultBean = newItem.getBean();
- }
- }
- }
- //
- // Set the default selection
- //
- if (defaultBean != null) {
- this.tableAttributes.select(defaultBean);
- }
- }
-
- @Override
- public void commit() {
- this.comboBoxCategories.commit();
- this.tableAttributes.commit();
- this.tableDatatypes.commit();
- }
-
- @Override
- public Attribute getAttribute() {
- Object categoryId = this.comboBoxCategories.getValue();
- Object attributeId = this.tableAttributes.getValue();
- Object datatypeId = this.tableDatatypes.getValue();
- if (attributeId == null || datatypeId == null || categoryId == null) {
- return null;
- }
- AttributeBean attributeBean = this.container.getItem(attributeId).getBean();
- Datatype datatype = AttributeStandardSelectorComponent.datatypes.getItem(datatypeId).getEntity();
- Category category = AttributeStandardSelectorComponent.categories.getItem(categoryId).getEntity();
- if (datatype == null || category == null) {
- return null;
- }
- Attribute attribute = new Attribute(attributeBean.getAttributeId().stringValue());
- attribute.setCategoryBean(category);
- attribute.setDatatypeBean(datatype);
-
- return attribute;
- }
-
- @Override
- public boolean addListener(AttributeChangedEventListener listener) {
- return this.notifier.addListener(listener);
- }
-
- @Override
- public boolean removeListener(AttributeChangedEventListener listener) {
- return this.notifier.removeListener(listener);
- }
-
- @Override
- public void fireAttributeChanged(Attribute attribute) {
- this.notifier.fireAttributeChanged(attribute);
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(false);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // comboBoxCategories
- comboBoxCategories = new ComboBox();
- comboBoxCategories.setCaption("Select A Category");
- comboBoxCategories.setImmediate(false);
- comboBoxCategories.setWidth("-1px");
- comboBoxCategories.setHeight("-1px");
- comboBoxCategories.setInvalidAllowed(false);
- comboBoxCategories.setRequired(true);
- mainLayout.addComponent(comboBoxCategories);
- mainLayout.setExpandRatio(comboBoxCategories, 1.0f);
-
- // horizontalLayout_2
- horizontalLayout_2 = buildHorizontalLayout_2();
- mainLayout.addComponent(horizontalLayout_2);
- mainLayout.setExpandRatio(horizontalLayout_2, 1.0f);
-
- return mainLayout;
- }
-
- @AutoGenerated
- private HorizontalLayout buildHorizontalLayout_2() {
- // common part: create layout
- horizontalLayout_2 = new HorizontalLayout();
- horizontalLayout_2.setImmediate(false);
- horizontalLayout_2.setWidth("-1px");
- horizontalLayout_2.setHeight("-1px");
- horizontalLayout_2.setMargin(false);
- horizontalLayout_2.setSpacing(true);
-
- // tableAttributes
- tableAttributes = new Table();
- tableAttributes.setCaption("Standard Attributes");
- tableAttributes.setImmediate(false);
- tableAttributes.setWidth("-1px");
- tableAttributes.setHeight("-1px");
- tableAttributes.setInvalidAllowed(false);
- tableAttributes.setRequired(true);
- horizontalLayout_2.addComponent(tableAttributes);
-
- // tableDatatypes
- tableDatatypes = new Table();
- tableDatatypes.setCaption("Standard Data Types");
- tableDatatypes.setImmediate(false);
- tableDatatypes.setWidth("-1px");
- tableDatatypes.setHeight("-1px");
- tableDatatypes.setInvalidAllowed(false);
- tableDatatypes.setRequired(true);
- horizontalLayout_2.addComponent(tableDatatypes);
-
- return horizontalLayout_2;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
deleted file mode 100644
index ab466b0..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
-import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
-import org.apache.openaz.xacml.std.pip.engines.csv.CSVEngine;
-import com.vaadin.addon.jpacontainer.EntityItem;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.data.util.converter.StringToIntegerConverter;
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class CSVPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
-
- @AutoGenerated
- private VerticalLayout mainLayout;
-
- @AutoGenerated
- private TextField textFieldSkip;
-
- @AutoGenerated
- private TextField textFieldQuote;
-
- @AutoGenerated
- private TextField textFieldDelimiter;
-
- @AutoGenerated
- private TextField textFieldFile;
-
- public static String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.csv.CSVEngine";
-
-
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Log logger = LogFactory.getLog(CSVPIPConfigurationComponent.class);
- private final CSVPIPConfigurationComponent self = this;
- private final BasicNotifier notifier = new BasicNotifier();
- private final EntityItem<PIPConfiguration> entity;
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- * @param entityConfig
- * @param configParamField
- */
- public CSVPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // Save
- //
- this.entity = entityConfig;
- //
- // initialize
- //
- this.initialize();
- //
- // Focus
- //
- this.textFieldFile.focus();
- }
-
- protected void initialize() {
- if (logger.isDebugEnabled()) {
- logger.debug("initializing " + this.entity.getEntity().toString());
- }
- //
- // What are our current values?
- //
- Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
- for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
- if (param.getParamName().equals(CSVEngine.PROP_SOURCE)) {
- this.textFieldFile.setData(param);
- } else if (param.getParamName().equals(CSVEngine.PROP_DELIMITER)) {
- this.textFieldDelimiter.setData(param);
- } else if (param.getParamName().equals(CSVEngine.PROP_QUOTE)) {
- this.textFieldQuote.setData(param);
- } else if (param.getParamName().equals(CSVEngine.PROP_SKIP)) {
- this.textFieldSkip.setData(param);
- } else {
- unneeded.add(param);
- }
- }
- if (unneeded.isEmpty() == false) {
- this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
- }
- //
- //
- //
- this.initializeEntity();
- this.initializeText();
- }
-
- protected void initializeEntity() {
- //
- // Initialize the entity
- //
- this.entity.getEntity().setClassname(CLASSNAME);
- this.entity.getEntity().setRequiresResolvers(true);
- }
-
- protected void initializeText() {
- //
- //
- //
- this.textFieldFile.setRequired(true);
- this.textFieldFile.setRequiredError("You need to specify a path to the CSV file on the server.");
- this.textFieldFile.setImmediate(true);
- this.textFieldFile.setNullRepresentation("");
- //
- //
- //
- PIPConfigParam param = (PIPConfigParam) this.textFieldFile.getData();
- if (param != null) {
- this.textFieldFile.setValue(param.getParamValue());
- }
- this.textFieldFile.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldFile.getData();
- if (param == null) {
- param = new PIPConfigParam(CSVEngine.PROP_SOURCE);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldFile.setData(param);
- }
- param.setParamValue(self.textFieldFile.getValue());
- self.fireFormChangedEvent();
- }
- });
- this.textFieldFile.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void textChange(TextChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldFile.getData();
- if (param == null) {
- param = new PIPConfigParam(CSVEngine.PROP_SOURCE);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldFile.setData(param);
- }
- param.setParamValue(self.textFieldFile.getValue());
- self.fireFormChangedEvent();
- }
- });
- //
- //
- //
- this.textFieldDelimiter.setNullRepresentation("");
- param = (PIPConfigParam) this.textFieldDelimiter.getData();
- if (param != null) {
- this.textFieldDelimiter.setValue(param.getParamValue());
- }
- this.textFieldDelimiter.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldDelimiter.getData();
- if (param == null) {
- param = new PIPConfigParam(CSVEngine.PROP_DELIMITER);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldDelimiter.setData(param);
- }
- param.setParamValue(self.textFieldDelimiter.getValue());
- self.fireFormChangedEvent();
- }
- });
- //
- //
- //
- this.textFieldQuote.setNullRepresentation("");
- param = (PIPConfigParam) this.textFieldQuote.getData();
- if (param != null) {
- this.textFieldQuote.setValue(param.getParamValue());
- }
- this.textFieldQuote.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldQuote.getData();
- if (param == null) {
- param = new PIPConfigParam(CSVEngine.PROP_QUOTE);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldQuote.setData(param);
- }
- param.setParamValue(self.textFieldQuote.getValue());
- self.fireFormChangedEvent();
- }
- });
- //
- //
- //
- this.textFieldSkip.setNullRepresentation("");
- param = (PIPConfigParam) this.textFieldSkip.getData();
- if (param != null) {
- this.textFieldSkip.setValue(param.getParamValue());
- }
- this.textFieldSkip.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldSkip.getData();
- if (param == null) {
- param = new PIPConfigParam(CSVEngine.PROP_SKIP);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldSkip.setData(param);
- }
- param.setParamValue(self.textFieldSkip.getValue());
- self.fireFormChangedEvent();
- }
- });
- this.textFieldSkip.setConverter(new StringToIntegerConverter());
- }
-
- public void validate() throws InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("validate");
- }
- this.textFieldFile.validate();
- this.textFieldDelimiter.validate();
- this.textFieldQuote.validate();
- this.textFieldSkip.validate();
- }
-
- public void commit() throws SourceException, InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("commit");
- }
- this.textFieldFile.commit();
- this.textFieldDelimiter.commit();
- this.textFieldQuote.commit();
-
- if (this.textFieldSkip.getValue() == null || this.textFieldSkip.getValue().isEmpty()) {
- this.entity.getEntity().removePipconfigParam((PIPConfigParam) this.textFieldSkip.getData());
- this.textFieldSkip.setData(null);
- }
- this.textFieldSkip.commit();
- }
-
- public void discard() throws SourceException {
- if (logger.isDebugEnabled()) {
- logger.debug("discard");
- }
- this.textFieldFile.discard();
- this.textFieldDelimiter.discard();
- this.textFieldQuote.discard();
- this.textFieldSkip.discard();
-
- this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_SOURCE);
- this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_DELIMITER);
- this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_QUOTE);
- this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_SKIP);
- this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_MAXSIZE);
- }
-
- @Override
- public boolean addListener(FormChangedEventListener listener) {
- return this.notifier.addListener(listener);
- }
-
- @Override
- public boolean removeListener(FormChangedEventListener listener) {
- return this.notifier.removeListener(listener);
- }
-
- @Override
- public void fireFormChangedEvent() {
- this.notifier.fireFormChangedEvent();
- }
-
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldFile
- textFieldFile = new TextField();
- textFieldFile.setCaption("Path to CSV File");
- textFieldFile.setImmediate(false);
- textFieldFile
- .setDescription("This is the path to CSV file on the PDP node.");
- textFieldFile.setWidth("-1px");
- textFieldFile.setHeight("-1px");
- textFieldFile.setInvalidAllowed(false);
- textFieldFile.setRequired(true);
- textFieldFile
- .setInputPrompt("Eg. \"c:\\data.csv\" \"http://foo.com/data.csv\"");
- mainLayout.addComponent(textFieldFile);
- mainLayout.setExpandRatio(textFieldFile, 1.0f);
-
- // textFieldDelimiter
- textFieldDelimiter = new TextField();
- textFieldDelimiter.setCaption("Delimiter");
- textFieldDelimiter.setImmediate(false);
- textFieldDelimiter
- .setDescription("Enter a separator character or string that delineates columns in each row.");
- textFieldDelimiter.setWidth("-1px");
- textFieldDelimiter.setHeight("-1px");
- textFieldDelimiter.setInputPrompt("Eg. \",\" or \"|\"");
- textFieldDelimiter.setNullSettingAllowed(true);
- mainLayout.addComponent(textFieldDelimiter);
- mainLayout.setExpandRatio(textFieldDelimiter, 1.0f);
-
- // textFieldQuote
- textFieldQuote = new TextField();
- textFieldQuote.setCaption("Quote");
- textFieldQuote.setImmediate(false);
- textFieldQuote
- .setDescription("Enter character used for quoted elements.");
- textFieldQuote.setWidth("-1px");
- textFieldQuote.setHeight("-1px");
- textFieldQuote.setInputPrompt("Eg. \" or '");
- textFieldQuote.setNullSettingAllowed(true);
- mainLayout.addComponent(textFieldQuote);
-
- // textFieldSkip
- textFieldSkip = new TextField();
- textFieldSkip.setCaption("Skip Lines");
- textFieldSkip.setImmediate(false);
- textFieldSkip
- .setDescription("Skips the number of lines at the beginning of the file.");
- textFieldSkip.setWidth("-1px");
- textFieldSkip.setHeight("-1px");
- textFieldSkip.setInputPrompt("Eg. 1 or 2");
- mainLayout.addComponent(textFieldSkip);
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
deleted file mode 100644
index 043cba7..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
-import org.apache.openaz.xacml.admin.jpa.PIPResolver;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
-import com.vaadin.addon.jpacontainer.EntityItem;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class CustomPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private PIPParameterComponent pipParameterComponent;
- @AutoGenerated
- private TextField textFieldClassname;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final EntityItem<?> entity;
- private static final Log logger = LogFactory.getLog(CustomPIPConfigurationComponent.class);
- private final CustomPIPConfigurationComponent self = this;
- private final BasicNotifier notifier = new BasicNotifier();
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- * @param configParamField
- */
- public CustomPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
- //
- // Save
- //
- this.entity = entityConfig;
-
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // InitializeGUI
- //
- this.initialize();
- }
-
- protected void initialize() {
- if (logger.isDebugEnabled()) {
- logger.debug("initializing " + this.entity.getEntity().toString());
- }
- this.initializeEntity();
- this.initializeText();
- }
-
- protected void initializeEntity() {
- //
- // If the entity is persisted, then we are editing
- // it. So don't remove anything.
- //
- if (this.entity.isPersistent()) {
- return;
- }
- //
- // Not sure if we really should remove stuff. To be
- // determined later.
- //
- }
-
- protected void initializeText() {
- this.textFieldClassname.setRequired(true);
- this.textFieldClassname.setRequiredError("You must declare the Java classname for the PIP Factory Loader");
- this.textFieldClassname.setImmediate(true);
- final Object entity = this.entity.getEntity();
- if (entity instanceof PIPConfiguration) {
- this.textFieldClassname.setValue(((PIPConfiguration)entity).getClassname());
- } else if (entity instanceof PIPResolver) {
- this.textFieldClassname.setValue(((PIPResolver)entity).getClassname());
- }
- //
- // Respond to events
- //
- this.textFieldClassname.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- if (entity instanceof PIPConfiguration) {
- ((PIPConfiguration) entity).setClassname(self.textFieldClassname.getValue());
- } else if (entity instanceof PIPResolver) {
- ((PIPResolver) entity).setClassname(self.textFieldClassname.getValue());
- }
- self.fireFormChangedEvent();
- }
- });
- }
-
- public void validate() throws InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("validate");
- }
- this.textFieldClassname.validate();
- }
-
- public void commit() throws SourceException, InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("commit");
- }
- this.textFieldClassname.commit();
- }
-
- public void discard() throws SourceException {
- if (logger.isDebugEnabled()) {
- logger.debug("discard");
- }
- }
-
- @Override
- public boolean addListener(FormChangedEventListener listener) {
- return this.notifier.addListener(listener);
- }
-
- @Override
- public boolean removeListener(FormChangedEventListener listener) {
- return this.notifier.removeListener(listener);
- }
-
- @Override
- public void fireFormChangedEvent() {
- this.notifier.fireFormChangedEvent();
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(false);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldClassname
- textFieldClassname = new TextField();
- textFieldClassname.setCaption("Java Classname");
- textFieldClassname.setImmediate(false);
- textFieldClassname
- .setDescription("Java classname of the code implementing the custom PIP.");
- textFieldClassname.setWidth("-1px");
- textFieldClassname.setHeight("-1px");
- textFieldClassname.setInputPrompt("Eg. com.foo.MyPIP");
- mainLayout.addComponent(textFieldClassname);
- mainLayout.setExpandRatio(textFieldClassname, 1.0f);
-
- // pipParameterComponent
- pipParameterComponent = new PIPParameterComponent(this.entity.getEntity());
- pipParameterComponent.setImmediate(false);
- pipParameterComponent.setWidth("-1px");
- pipParameterComponent.setHeight("-1px");
- mainLayout.addComponent(pipParameterComponent);
-
- return mainLayout;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
deleted file mode 100644
index eafbcad..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.jpa.Attribute;
-import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
-import org.apache.openaz.xacml.api.Identifier;
-import org.apache.openaz.xacml.api.XACML3;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TableFieldFactory;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class EnumerationEditorComponent extends CustomComponent implements Validator {
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
-
- @AutoGenerated
- private HorizontalLayout horizontalLayout_1;
-
- @AutoGenerated
- private Button buttonClearAll;
-
- @AutoGenerated
- private Button buttonRemove;
-
- @AutoGenerated
- private Button buttonAdd;
-
- @AutoGenerated
- private Table tableEnumerations;
-
- private static final long serialVersionUID = -1L;
- private static final Log logger = LogFactory.getLog(EnumerationEditorComponent.class);
- private final EnumerationEditorComponent self = this;
- private final Attribute attribute;
- private Identifier datatype;
- private final BeanItemContainer<ConstraintValue> beanContainer;
-
- public EnumerationEditorComponent(Attribute attribute, Identifier datatype) {
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // Save our attribute
- //
- this.attribute = attribute;
- this.datatype = datatype;
- //
- // Construct a bean container that the
- // table uses to manage the values.
- //
- this.beanContainer = new BeanItemContainer<ConstraintValue>(ConstraintValue.class);
- //
- // Initialize our components
- //
- this.initializeTable();
- this.initializeButtons();
- }
-
- private void initializeTable() {
- //
- // Add the current enumeration values into the
- // bean container.
- //
- for (ConstraintValue value : this.attribute.getConstraintValues()) {
- if (value.getProperty().equals("Enumeration")) {
- this.beanContainer.addBean(value);
- }
- }
- //
- // Now hook the bean container to the table
- //
- this.tableEnumerations.setContainerDataSource(beanContainer);
- //
- // We have to manually create the text field because we need
- // to set a validator.
- //
- this.tableEnumerations.setTableFieldFactory(new TableFieldFactory() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Field<?> createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
- if (propertyId.toString().equals("value")) {
- final TextField text = new TextField();
- text.setImmediate(true);
- text.setNullRepresentation("");
- text.setNullSettingAllowed(false);
- text.setRequired(true);
- text.setRequiredError("Cannot have empty enumeration values.");
- text.addValidator(self);
- return text;
- }
- return null;
- }
- });
- //
- // Finish setting up the table.
- //
- this.tableEnumerations.setVisibleColumns(new Object[] {"value"});
- this.tableEnumerations.setColumnHeaders(new String[] {"Enumeration Value"});
- this.tableEnumerations.setSelectable(true);
- this.tableEnumerations.setEditable(true);
- this.tableEnumerations.setImmediate(true);
- if (this.tableEnumerations.size() == 0) {
- this.tableEnumerations.setPageLength(3);
- } else {
- this.tableEnumerations.setPageLength(this.tableEnumerations.size() + 1);
- }
- //
- // As the user select items, enable/disable buttons
- //
- this.tableEnumerations.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.buttonRemove.setEnabled(self.tableEnumerations.getValue() != null);
- }
-
- });
- }
-
- private void initializeButtons() {
- //
- // Adding new values
- //
- this.buttonAdd.setImmediate(true);
- this.buttonAdd.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- //
- // Create a new value object
- //
- ConstraintValue newValue = new ConstraintValue("Enumeration", "");
- //
- // Associate it with the attribute
- //
- newValue.setAttribute(self.attribute);
- //
- // Add it into the attribute's internal list
- //
- self.attribute.addConstraintValue(newValue);
- //
- // Now we can add it to the GUI
- //
- Item item = self.tableEnumerations.addItem(newValue);
- if (item != null) {
- self.tableEnumerations.select(newValue);
- self.tableEnumerations.focus();
- }
- //
- // Make sure this button is now enabled
- //
- self.buttonClearAll.setEnabled(true);
- }
- });
- //
- // Removing values - nothing is selected to begin with so
- // disable the button.
- //
- this.buttonRemove.setEnabled(false);
- this.buttonRemove.setImmediate(true);
- this.buttonRemove.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- //
- // Get the selected value
- //
- Object value = self.tableEnumerations.getValue();
- //
- // Was it selected or unselected (i.e. null)? If so, remove it
- // from the table
- //
- if (value != null && self.tableEnumerations.removeItem(value)) {
- //
- // Dis-associate it with the attribute
- //
- ((ConstraintValue) value).setAttribute(null);
- //
- // Now remove it from the attribute's internal list
- //
- self.attribute.removeConstraintValue((ConstraintValue) value);
- //
- // If there are no items, then disable this button
- //
- if (self.tableEnumerations.size() == 0) {
- self.buttonClearAll.setEnabled(false);
- }
- }
- }
-
- });
- //
- // Clearing all the values, set it enabled if we have anything
- //
- this.buttonClearAll.setImmediate(true);
- this.buttonClearAll.setEnabled(this.tableEnumerations.size() > 0);
- this.buttonClearAll.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- //
- // Iterate all the values
- //
- for (Object id : self.tableEnumerations.getItemIds()) {
- //
- // Get the value object (it is the id)
- //
- ConstraintValue value = (ConstraintValue) id;
- //
- // Dis-associate it with the attribute
- //
- value.setAttribute(null);
- //
- // Now remove it from the attribute's internal list
- //
- self.attribute.removeConstraintValue(value);
- }
- //
- // Remove everything from the table
- //
- self.tableEnumerations.removeAllItems();
- //
- // Now disable this button
- //
- self.buttonClearAll.setEnabled(false);
- }
- });
- }
-
- public void setupDatatype(Identifier id) {
- if (logger.isTraceEnabled()) {
- logger.trace("setupDatatype: " + datatype);
- }
- this.datatype = id;
- //
- // Initiate a validate
- //
- this.tableEnumerations.validate();
- }
-
- @Override
- public void validate(Object value) throws InvalidValueException {
- if (value == null || value.toString().length() == 0) {
- return;
- }
- if (datatype.equals(XACML3.ID_DATATYPE_INTEGER)) {
- try {
- Integer.parseInt(value.toString());
- } catch(NumberFormatException e) {
- throw new InvalidValueException(e.getLocalizedMessage());
- }
- return;
- }
- if (datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
- try {
- Double.parseDouble(value.toString());
- } catch(NumberFormatException e) {
- throw new InvalidValueException(e.getLocalizedMessage());
- }
- return;
- }
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // tableEnumerations
- tableEnumerations = new Table();
- tableEnumerations.setCaption("Enumeration Values");
- tableEnumerations.setImmediate(true);
- tableEnumerations
- .setDescription("Enter possible values for the attribute.");
- tableEnumerations.setWidth("100.0%");
- tableEnumerations.setHeight("-1px");
- tableEnumerations.setInvalidAllowed(false);
- mainLayout.addComponent(tableEnumerations);
- mainLayout.setExpandRatio(tableEnumerations, 1.0f);
-
- // horizontalLayout_1
- horizontalLayout_1 = buildHorizontalLayout_1();
- mainLayout.addComponent(horizontalLayout_1);
- mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
-
- return mainLayout;
- }
-
- @AutoGenerated
- private HorizontalLayout buildHorizontalLayout_1() {
- // common part: create layout
- horizontalLayout_1 = new HorizontalLayout();
- horizontalLayout_1.setImmediate(false);
- horizontalLayout_1.setWidth("-1px");
- horizontalLayout_1.setHeight("-1px");
- horizontalLayout_1.setMargin(false);
- horizontalLayout_1.setSpacing(true);
-
- // buttonAdd
- buttonAdd = new Button();
- buttonAdd.setCaption("Add");
- buttonAdd.setImmediate(true);
- buttonAdd.setDescription("Add a new enumeration value.");
- buttonAdd.setWidth("-1px");
- buttonAdd.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonAdd);
- horizontalLayout_1.setComponentAlignment(buttonAdd, new Alignment(9));
-
- // buttonRemove
- buttonRemove = new Button();
- buttonRemove.setCaption("Remove");
- buttonRemove.setImmediate(true);
- buttonRemove.setDescription("Remove the selected enumeration value.");
- buttonRemove.setWidth("-1px");
- buttonRemove.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonRemove);
- horizontalLayout_1.setComponentAlignment(buttonRemove,
- new Alignment(10));
-
- // buttonClearAll
- buttonClearAll = new Button();
- buttonClearAll.setCaption("Clear All");
- buttonClearAll.setImmediate(false);
- buttonClearAll.setDescription("Clears all the values out.");
- buttonClearAll.setWidth("-1px");
- buttonClearAll.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonClearAll);
-
- return horizontalLayout_1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
deleted file mode 100644
index 67f7faf..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.components;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
-import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
-import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
-import org.apache.openaz.xacml.std.pip.engines.csv.HyperCSVEngine;
-import com.vaadin.addon.jpacontainer.EntityItem;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class HyperCSVPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private TextField textFieldDefinition;
- @AutoGenerated
- private TextField textFieldTarget;
- @AutoGenerated
- private TextField textFieldSource;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public static final String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.csv.HyperCSVEngine";
-
- private final EntityItem<PIPConfiguration> entity;
- private static final Log logger = LogFactory.getLog(CustomPIPConfigurationComponent.class);
- private final HyperCSVPIPConfigurationComponent self = this;
- private final BasicNotifier notifier = new BasicNotifier();
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public HyperCSVPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
- buildMainLayout();
- setCompositionRoot(mainLayout);
- //
- // Save
- //
- this.entity = entityConfig;
- //
- // Initialize
- //
- this.initialize();
- }
-
- protected void initialize() {
- if (logger.isDebugEnabled()) {
- logger.debug("initializing " + this.entity.getEntity().toString());
- }
- //
- // What are our current values?
- //
- Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
- for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
- if (param.getParamName().equals(HyperCSVEngine.PROP_SOURCE)) {
- this.textFieldSource.setData(param);
- } else if (param.getParamName().equals(HyperCSVEngine.PROP_TARGET)) {
- this.textFieldTarget.setData(param);
- } else if (param.getParamName().equals(HyperCSVEngine.PROP_DEFINITION)) {
- this.textFieldDefinition.setData(param);
- } else {
- unneeded.add(param);
- }
- }
- if (unneeded.isEmpty() == false) {
- this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
- }
- //
- //
- //
- this.initializeEntity();
- this.initializeText();
- }
-
- protected void initializeEntity() {
- //
- // Initialize the entity
- //
- this.entity.getEntity().setClassname(CLASSNAME);
- this.entity.getEntity().setRequiresResolvers(true);
- }
-
- protected void initializeText() {
- //
- //
- //
- this.textFieldSource.setNullRepresentation("");
- PIPConfigParam param = (PIPConfigParam) this.textFieldSource.getData();
- if (param != null) {
- this.textFieldSource.setValue(param.getParamValue());
- }
- this.textFieldSource.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void textChange(TextChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldSource.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_SOURCE);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldSource.setData(param);
- }
- param.setParamValue(self.textFieldSource.getValue());
- self.fireFormChangedEvent();
- }
- });
- this.textFieldSource.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldSource.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_SOURCE);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldSource.setData(param);
- }
- param.setParamValue(self.textFieldSource.getValue());
- self.fireFormChangedEvent();
- }
- });
- //
- //
- //
- this.textFieldTarget.setNullRepresentation("");
- param = (PIPConfigParam) this.textFieldTarget.getData();
- if (param != null) {
- this.textFieldTarget.setValue(param.getParamValue());
- }
- this.textFieldTarget.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void textChange(TextChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldTarget.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_TARGET);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldTarget.setData(param);
- }
- param.setParamValue(self.textFieldTarget.getValue());
- self.fireFormChangedEvent();
- }
- });
- this.textFieldTarget.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldTarget.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_TARGET);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldTarget.setData(param);
- }
- param.setParamValue(self.textFieldTarget.getValue());
- self.fireFormChangedEvent();
- }
- });
- //
- //
- //
- this.textFieldDefinition.setNullRepresentation("");
- param = (PIPConfigParam) this.textFieldDefinition.getData();
- if (param != null) {
- this.textFieldDefinition.setValue(param.getParamValue());
- }
- this.textFieldDefinition.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void textChange(TextChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldDefinition.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_DEFINITION);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldDefinition.setData(param);
- }
- param.setParamValue(self.textFieldDefinition.getValue());
- self.fireFormChangedEvent();
- }
- });
- this.textFieldDefinition.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- PIPConfigParam param = (PIPConfigParam) self.textFieldDefinition.getData();
- if (param == null) {
- param = new PIPConfigParam(HyperCSVEngine.PROP_DEFINITION);
- self.entity.getEntity().addPipconfigParam(param);
- self.textFieldDefinition.setData(param);
- }
- param.setParamValue(self.textFieldDefinition.getValue());
- self.fireFormChangedEvent();
- }
- });
- }
-
- public void validate() throws InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("validate");
- }
- this.textFieldSource.validate();
- this.textFieldTarget.validate();
- this.textFieldDefinition.validate();
- }
-
- public void commit() throws SourceException, InvalidValueException {
- if (logger.isDebugEnabled()) {
- logger.debug("commit");
- }
- this.textFieldSource.commit();
- this.textFieldTarget.commit();
- this.textFieldDefinition.commit();
- }
-
- public void discard() throws SourceException {
- if (logger.isDebugEnabled()) {
- logger.debug("discard");
- }
- this.textFieldSource.discard();
- this.textFieldTarget.discard();
- this.textFieldDefinition.discard();
- //??
- this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_SOURCE);
- this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_TARGET);
- this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_DEFINITION);
- }
-
- @Override
- public boolean addListener(FormChangedEventListener listener) {
- return this.notifier.addListener(listener);
- }
-
- @Override
- public boolean removeListener(FormChangedEventListener listener) {
- return this.notifier.removeListener(listener);
- }
-
- @Override
- public void fireFormChangedEvent() {
- this.notifier.fireFormChangedEvent();
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(false);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldSource
- textFieldSource = new TextField();
- textFieldSource.setCaption("CSV Source File");
- textFieldSource.setImmediate(false);
- textFieldSource.setDescription("Path to CSV file");
- textFieldSource.setWidth("-1px");
- textFieldSource.setHeight("-1px");
- textFieldSource.setInvalidAllowed(false);
- textFieldSource.setRequired(true);
- textFieldSource.setInputPrompt("Eg. /opt/app/data.csv");
- mainLayout.addComponent(textFieldSource);
-
- // textFieldTarget
- textFieldTarget = new TextField();
- textFieldTarget.setCaption("Table");
- textFieldTarget.setImmediate(false);
- textFieldTarget.setDescription("Name of database table to be created.");
- textFieldTarget.setWidth("-1px");
- textFieldTarget.setHeight("-1px");
- textFieldTarget.setInvalidAllowed(false);
- textFieldTarget.setRequired(true);
- mainLayout.addComponent(textFieldTarget);
-
- // textFieldDefinition
- textFieldDefinition = new TextField();
- textFieldDefinition.setCaption("Table Definition");
- textFieldDefinition.setImmediate(false);
- textFieldDefinition.setDescription("SQL Table Definition");
- textFieldDefinition.setWidth("-1px");
- textFieldDefinition.setHeight("-1px");
- textFieldDefinition.setInvalidAllowed(false);
- textFieldDefinition.setRequired(true);
- mainLayout.addComponent(textFieldDefinition);
-
- return mainLayout;
- }
-
-}