public static ActionInsertFactCol52 createActionInsertFact(String factType, String boundName, String factField, String type) { ActionInsertFactCol52 column = new ActionInsertFactCol52(); column.setFactType(factType); column.setBoundName(boundName); column.setFactField(factField); column.setType(type); return column; } }
private void update(final ActionInsertFactCol52 originalColumn, final ActionInsertFactCol52 editedColumn) { originalColumn.setBoundName(editedColumn.getBoundName()); originalColumn.setType(editedColumn.getType()); originalColumn.setFactField(editedColumn.getFactField()); originalColumn.setHeader(editedColumn.getHeader()); originalColumn.setValueList(editedColumn.getValueList()); originalColumn.setDefaultValue(editedColumn.getDefaultValue()); originalColumn.setHideColumn(editedColumn.isHideColumn()); originalColumn.setFactType(editedColumn.getFactType()); originalColumn.setInsertLogical(editedColumn.isInsertLogical()); if (originalColumn instanceof LimitedEntryCol && editedColumn instanceof LimitedEntryCol) { ((LimitedEntryCol) originalColumn).setValue(((LimitedEntryCol) editedColumn).getValue()); } }
public ActionInsertFactColumnDetails( final ActionInsertFactCol52 column ) { super( column ); this.factType = column.getFactType(); this.factField = column.getFactField(); }
private ActionInsertFactCol52 makeNewColumn(ActionInsertFactCol c) { ActionInsertFactCol52 nc = new ActionInsertFactCol52(); nc.setBoundName(c.boundName); nc.setDefaultValue(new DTCellValue52(c.defaultValue)); nc.setFactField(c.factField); nc.setFactType(c.factType); nc.setHeader(c.header); nc.setHideColumn(c.hideColumn); nc.setType(c.type); nc.setValueList(c.valueList); nc.setWidth(c.width); return nc; }
@Test public void appendActionColumn() throws VetoException { reset(modellerPresenter); final ActionInsertFactCol52 action = new ActionInsertFactCol52(); action.setFactType("FactType"); action.setFactField("field"); action.setHeader("header"); when(oracle.getFieldType(eq("FactType"), eq("field"))).thenReturn(DataType.TYPE_STRING); dtPresenter.appendColumn(action); verify(synchronizer, times(1)).appendColumn(eq(action)); verify(refreshActionsPanelEvent, times(1)).fire(any(RefreshActionsPanelEvent.class)); verify(modellerPresenter, times(1)).updateLinks(); }
@Test public void testUpdate() throws VetoException { final ActionInsertFactCol52 column = spy(new ActionInsertFactCol52()); column.setHeader("col1"); column.setBoundName("$a"); column.setFactType("Applicant"); column.setFactField("age"); modelSynchronizer.appendColumn(column); final ActionInsertFactCol52 edited = new ActionInsertFactCol52(); edited.setWidth(column.getWidth()); edited.setBoundName("$a"); edited.setFactType("Applicant"); edited.setFactField("name"); edited.setHideColumn(true); edited.setHeader("updated"); List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited); assertEquals(3, diffs.size()); verify(column).diff(edited); assertEquals(1, model.getActionCols().size()); assertEquals(3, uiModel.getColumns().size()); assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn); assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle()); assertEquals(false, uiModel.getColumns().get(2).isVisible()); }
@Test public void getSafeHtml_ActionInsert() { //hide, insert, value list, default value, field, header ActionInsertFactCol52 originalColumn = new ActionInsertFactCol52(); originalColumn.setFactField("field1"); originalColumn.setInsertLogical(false); originalColumn.setValueList("q,w,e"); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); originalColumn.setDefaultValue(new DTCellValue52("def1")); ActionInsertFactCol52 newColumn = new ActionInsertFactCol52(); newColumn.setFactField("field2"); newColumn.setInsertLogical(true); newColumn.setValueList("a,s,d"); newColumn.setHeader("action2"); newColumn.setHideColumn(true); newColumn.setDefaultValue(new DTCellValue52("def2")); List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn); SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs)); assertEquals(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString()); }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction(actions, ac.getBoundName()); if (a == null) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if (!ac.isInsertLogical()) { ActionInsertFact ins = new ActionInsertFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } actions.add(a); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue(ac.getFactField(), cell, ac.getType()); ins.addFieldValue(val); }
if ( !isEqualOrNull( this.getFactType(), other.getFactType() ) ) { result.add( new BaseColumnFieldDiffImpl( FIELD_FACT_TYPE, this.getFactType(), other.getFactType() ) ); if ( !isEqualOrNull( this.getBoundName(), other.getBoundName() ) ) { result.add( new BaseColumnFieldDiffImpl( FIELD_BOUND_NAME, this.getBoundName(), other.getBoundName() ) ); if ( !isEqualOrNull( this.getFactField(), other.getFactField() ) ) { result.add( new BaseColumnFieldDiffImpl( FIELD_FACT_FIELD, this.getFactField(), other.getFactField() ) ); if ( !isEqualOrNull( this.getType(), other.getType() ) ) { result.add( new BaseColumnFieldDiffImpl( FIELD_TYPE, this.getType(), other.getType() ) ); if ( !isEqualOrNull( this.getValueList(), other.getValueList() ) ) { result.add( new BaseColumnFieldDiffImpl( FIELD_VALUE_LIST, this.getValueList(), other.getValueList() ) );
@Test public void testGetValueInsertFactColumn() throws Exception { final ActionInsertFactCol52 column = new ActionInsertFactCol52(); column.setFactField(FIELD_NAME); column.setFactType(FACT_TYPE); column.setValueList("a,1,1.1, ,-1, 123,456 , -789 "); when(oracle.getFieldType(FACT_TYPE, FIELD_NAME)).thenReturn(DataType.TYPE_NUMERIC_INTEGER); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("1", "-1", "123", "456", "-789"); }
private void addActionInsertFactToModel(final GuidedDecisionTable52 model, final String factType, final String fieldName) { final ActionInsertFactCol52 aif = new ActionInsertFactCol52(); aif.setFactType(factType); aif.setFactField(fieldName); model.getActionCols().add(aif); }
@Test public void testSetFieldSelectionModel() throws Exception { verify(view.chosenFieldsContainer).add(chosenFieldsWidgetCaptor.capture()); fieldSelectionModel = (MultiSelectionModel<ActionInsertFactCol52>) chosenFieldsWidgetCaptor.getValue().getSelectionModel(); insertFactCol52 = new ActionInsertFactCol52(); insertFactCol52.setType("Applicant"); insertFactCol52.setFactField("age"); insertFactCol52.setType("Integer"); fieldSelectionModel.setSelected(insertFactCol52, true); assertTrue(fieldSelectionModel.isSelected(insertFactCol52)); insertFactCol52.setDefaultValue(new DTCellValue52(18)); assertTrue(fieldSelectionModel.isSelected(insertFactCol52)); }
@Override public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) { return new ArrayList<GridColumn.HeaderMetaData>() {{ if (column instanceof ActionInsertFactCol52) { ActionInsertFactCol52 actionInsertFactColumn = (ActionInsertFactCol52) column; StringBuilder headerFirstRow = new StringBuilder(); if (actionInsertFactColumn.getBoundName() != null && !actionInsertFactColumn.getBoundName().isEmpty()) { headerFirstRow.append(actionInsertFactColumn.getBoundName()) .append(" : "); } headerFirstRow.append(actionInsertFactColumn.getFactType()); add(new BaseHeaderMetaData(headerFirstRow.toString(), ActionCol52.class.getName())); add(new BaseHeaderMetaData(column.getHeader(), headerFirstRow.toString())); } else { add(new BaseHeaderMetaData(column.getHeader(), ActionCol52.class.getName())); } }}; } }
public ActionInsertFactCol52ActionInsertFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }
private String[] getValueList(final ActionInsertFactCol52 col) { if (col.getValueList() != null && !"".equals(col.getValueList())) { return parseValueList(getTypeFromDataOracle(col.getFactType(), col.getFactField()), col.getValueList()); } return new String[0]; }
@Override public void makeResult(final GuidedDecisionTable52 model) { //Copy actions to decision table model int fi = 1; for (Map.Entry<ActionInsertFactFieldsPattern, List<ActionInsertFactCol52>> ps : patternToActionsMap.entrySet()) { final ActionInsertFactFieldsPattern p = ps.getKey(); if (!getValidator().isPatternValid(p)) { String binding = NEW_FACT_PREFIX + (fi++); p.setBoundName(binding); while (!getValidator().isPatternBindingUnique(p)) { binding = NEW_FACT_PREFIX + (fi++); p.setBoundName(binding); } } final String factType = p.getFactType(); final String boundName = p.getBoundName(); final boolean isLogicalInsert = p.isInsertedLogically(); for (ActionInsertFactCol52 aif : ps.getValue()) { aif.setFactType(factType); aif.setBoundName(boundName); aif.setInsertLogical(isLogicalInsert); model.getActionCols().add(aif); } } }
@Override public String getBoundName() { return action.getBoundName(); }
@Override public String getFactField() { return getActionCol52().getFactField(); }
@Test public void testGetWidgetEnums() throws Exception { insertFactCol52.setFactType("Person"); insertFactCol52.setFactField("name"); when(oracle.hasEnums("Person", "name")).thenReturn(true); Widget widget = factory.getWidget(insertFactCol52, cellValue); assertTrue(widget instanceof ListBox); } }
private ActionInsertFactCol52 newActionInsertFact() { switch (tableFormat()) { case EXTENDED_ENTRY: return new ActionInsertFactCol52(); case LIMITED_ENTRY: return new LimitedEntryActionInsertFactCol52(); default: throw new UnsupportedOperationException("Unsupported table format: " + tableFormat()); } }