protected boolean maybeAddPerceivedObject(PerceptionMessage.ObjectNote objectNote) {
    ObjectType objType = (ObjectType) objectNote.getObjectType();
    long perceivedOid = objectNote.getSubject();
    long perceiverOid = objectNote.getTarget();
    if (perceivedOid == perceiverOid) return true;
    boolean callbackNixedIt = false;
    if (remoteObjectFilter != null)
      callbackNixedIt = !remoteObjectFilter.objectShouldBeTracked(perceivedOid, objectNote);
    if (callbackNixedIt || !(objType.isMob())) {
      //             if (Log.loggingDebug)
      //                 Log.debug("ProximityTracker.maybeAddPerceivedObject: ignoring oid=" +
      // perceivedOid
      //                     + " objType=" + objType
      //                     + " detected by " + perceiverOid
      //                     + ", instanceOid=" + instanceOid);
      return false;
    }

    if (Log.loggingDebug)
      Log.debug(
          "ProximityTracker.maybeAddPerceivedObject: oid="
              + perceivedOid
              + " objType="
              + objType
              + " detected by "
              + perceiverOid
              + ", instanceOid="
              + instanceOid);
    lock.lock();
    try {
      PerceiverData perceiverData = perceiverDataMap.get(perceiverOid);
      if (perceiverData == null) {
        Log.error(
            "ProximityTracker.maybeAddPerceivedObject: got perception msg with perceived obj oid="
                + perceivedOid
                + " for unknown perceiver="
                + perceiverOid);
        return false;
      }
      perceiverData.perceivedOids.add(perceivedOid);
      PerceiverData perceivedData = perceiverDataMap.get(perceivedOid);
      if (perceivedData != null) testProximity(perceiverData, perceivedData, true, false);
    } finally {
      lock.unlock();
    }
    return true;
  }
예제 #2
0
 @Override
 public Class<T> getTypeClass(ClassLoader loader) {
   try {
     return UtilGenerics.cast(ObjectType.loadClass(type, loader));
   } catch (ClassNotFoundException e) {
     Debug.logError(e, "Could not find class for type: " + type, module);
     return null;
   }
 }
예제 #3
0
  /** determines object type based on first type attribute it finds */
  public ObjectType getType() {
    for (RpslAttribute attribute : attributes) {
      final ObjectType objectType = ObjectType.getByNameOrNull(attribute.getKey());
      if (objectType != null) {
        return objectType;
      }
    }

    throw new IllegalStateException("No type attribute found");
  }
  private DbOOAdt toAdt(Type type) throws DbException {
    DbOOAdt adt = null;

    if (type instanceof BasicType) {
      BasicType basicType = (BasicType) type;
      adt = toBasicAdt(basicType);
    } else if (type instanceof ObjectType) {
      ObjectType ot = (ObjectType) type;
      String classname = ot.getClassName();
      adt = toAdt(classname, ot);
    } else if (type instanceof ArrayType) {
      ArrayType at = (ArrayType) type;
      adt = toAdt(at.getBasicType());
    } else {
      // other cases?
    } // end if

    return adt;
  }
예제 #5
0
 public static Boolean doRealCompare(
     Object value1,
     Object value2,
     String operator,
     String type,
     String format,
     List<Object> messages,
     Locale locale,
     ClassLoader loader,
     boolean value2InlineConstant) {
   return ObjectType.doRealCompare(
       value1, value2, operator, type, format, messages, locale, loader, value2InlineConstant);
 }
  protected Document getTestDocument() {
    ObjectType documentObjectType = mock(ObjectType.class);
    when(documentObjectType.getId()).thenReturn(BaseTypeId.CMIS_DOCUMENT.value());

    Document documentObject =
        createMockedCmisObject(
            new Object[][] {
              {PropertyIds.NAME, "Name", "A document name.txt"},
              {PropertyIds.CONTENT_STREAM_LENGTH, "Content Stream Length", "210"},
              {PropertyIds.BASE_TYPE_ID, "Base Type Id", "cmis:document"},
              {PropertyIds.OBJECT_TYPE_ID, "Object Type Id", "cmis:document"},
              {PropertyIds.LAST_MODIFICATION_DATE, "Last Modification Date", new Date(0)},
              {PropertyIds.OBJECT_TYPE_ID, "Object Type Id", "cmis:document"},
              {PropertyIds.CONTENT_STREAM_MIME_TYPE, "Content Stream Mime Type", "text/plain"},
              {PropertyIds.OBJECT_ID, "Object Type Id", TEST_DOCUMENT_ID}
            },
            Document.class);
    when(documentObject.getId()).thenReturn(TEST_DOCUMENT_ID);
    when(documentObject.getBaseType()).thenReturn(documentObjectType);

    return documentObject;
  }
예제 #7
0
 public static final com.redhat.persistence.metadata.ObjectType type(Root root, ObjectType type) {
   return type(root, type.getQualifiedName());
 }
예제 #8
0
  // region Constructor
  public ImportTableDialog(
      final Connection connection,
      String tableName,
      Iterable<TypedColumn> columns,
      final Iterable<String> columnFamilies) {
    setContentPane(this.contentPane);
    setModal(true);
    setTitle("Import table from file");
    getRootPane().setDefaultButton(this.btImport);

    this.tfTableName.setText(tableName);
    this.tfFilePath.setText(String.format("%s.csv", tableName));

    this.tableModel = new DefaultTableModel();
    this.rowsTable.setModel(this.tableModel);

    this.tableModel.addColumn("Column Name");
    this.tableModel.addColumn("Column Type");
    this.rowsTable.setRowHeight(this.rowsTable.getFont().getSize() + 8);
    this.rowsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    JComboBox comboBox = new JComboBox();

    for (ObjectType objectType : ObjectType.values()) {
      comboBox.addItem(objectType);
    }

    this.rowsTable.getColumn("Column Name").setCellEditor(new JCellEditor(null, false));
    this.rowsTable.getColumn("Column Type").setCellEditor(new DefaultCellEditor(comboBox));

    for (TypedColumn typedColumn : columns) {
      this.tableModel.addRow(new Object[] {typedColumn.getColumn(), typedColumn.getType(), null});
    }

    this.rowsTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                ImportTableDialog.this.btRemoveColumn.setEnabled(e.getFirstIndex() != -1);
              }
            });

    this.btImport.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (validateInput()) {
              onImport(connection);
            }
          }
        });

    this.btClose.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            dispose();
          }
        });

    // call onCancel() on ESCAPE
    this.contentPane.registerKeyboardAction(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    this.btBrowse.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JFileChooser dialog = new JFileChooser();
            dialog.setCurrentDirectory(new File("."));
            dialog.setSelectedFile(new File(ImportTableDialog.this.tfFilePath.getText()));

            int returnVal = dialog.showSaveDialog(ImportTableDialog.this.contentPane);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              ImportTableDialog.this.tfFilePath.setText(dialog.getSelectedFile().getAbsolutePath());
            }
          }
        });

    this.btAddColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            stopCellEditing(ImportTableDialog.this.rowsTable);

            AddColumnDialog dialog = new AddColumnDialog(columnFamilies);
            dialog.showDialog(ImportTableDialog.this);

            String columnName = dialog.getColumnName();
            if (columnName != null) {
              int rowIndex = getRowIndex(ImportTableDialog.this.rowsTable, 1, columnName);
              if (rowIndex == -1) {
                ImportTableDialog.this.tableModel.addRow(
                    new Object[] {columnName, ObjectType.String, null});
                rowIndex = ImportTableDialog.this.tableModel.getRowCount() - 1;
              }

              ImportTableDialog.this.rowsTable.setRowSelectionInterval(rowIndex, rowIndex);
            }
          }
        });

    this.btRemoveColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int selectedRow = ImportTableDialog.this.rowsTable.getSelectedRow();

            while (selectedRow != -1) {
              ImportTableDialog.this.tableModel.removeRow(selectedRow);
              selectedRow = ImportTableDialog.this.rowsTable.getSelectedRow();
            }

            ImportTableDialog.this.btRemoveColumn.setEnabled(false);
          }
        });

    this.btCancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ImportTableDialog.this.canceled = true;
          }
        });
  }