@Nullable
  private LookupFile getClosestParent(final String typed) {
    if (typed == null) return null;
    LookupFile lastFound = myFinder.find(typed);
    if (lastFound == null) return null;
    if (lastFound.exists()) {
      if (typed.charAt(typed.length() - 1) != File.separatorChar) return lastFound.getParent();
      return lastFound;
    }

    final String[] splits = myFinder.normalize(typed).split(myFileSpitRegExp);
    StringBuilder fullPath = new StringBuilder();
    for (int i = 0; i < splits.length; i++) {
      String each = splits[i];
      fullPath.append(each);
      if (i < splits.length - 1) {
        fullPath.append(myFinder.getSeparator());
      }
      final LookupFile file = myFinder.find(fullPath.toString());
      if (file == null || !file.exists()) return lastFound;
      lastFound = file;
    }

    return lastFound;
  }
 private void setTextToFile(final LookupFile file) {
   String text = file.getAbsolutePath();
   if (file.isDirectory() && !text.endsWith(myFinder.getSeparator())) {
     text += myFinder.getSeparator();
   }
   myPathTextField.setText(text);
 }
 public void testFindExample() {
   Finder query = new Finder(Example.class);
   Example result = query.where("name").isEqualTo("John Doe").result();
   assertNotNull(result);
   assertNotNull(result.id);
   assertEquals(result.name, "John Doe");
 }
  public static List<Path> getFileList(String directory, String pattern) throws IOException {

    Path startingDir = Paths.get(directory);

    Finder finder = new Finder(pattern);
    Files.walkFileTree(startingDir, finder);

    return finder.getFileList();
  }
  @Test
  public void testAssocBeanDepth() {

    Finder finder = new Finder();
    QOrder qOrder = finder.orderQuery();

    assertNotNull(qOrder.id);
    assertNotNull(qOrder.details.product);
  }
 @Override
 protected ExtendedIterator<Triple> processMethod() throws AsyncException {
   checkOpen();
   if (!isPrepared) prepare(getHandler(""));
   Finder cascade =
       transitiveEngine.getFinder(
           getHandler(""), pattern, FinderUtil.cascade(tbox, continuation));
   return UniqueExtendedIterator.create(cascade.find(getHandler(""), pattern));
 }
  @Test
  public void test() {

    Finder finder = new Finder();
    QAddress qAddress = finder.simpleFind();

    assertNotNull(qAddress.version);
    assertNotNull(qAddress.country);
    assertNotNull(qAddress.city);
  }
 public static boolean testSetup() {
   Region r = Region.create(0, 0, 100, 100);
   Image img = new Image(r.getScreen().capture(r).getImage());
   Pattern p = new Pattern(img);
   Finder f = new Finder(img);
   if (null != f.find(p) && f.hasNext()) {
     org.sikuli.basics.SikuliX.popup(
         "Hallo from Java-API.testSetup\nSikuli seems to be working fine!\n\nHave fun!");
     return true;
   }
   return false;
 }
  public static List<Showreel> all(User authUser) {
    // return find.all();
    List<Showreel> publiclist = find.where().eq("viewable", PUBLIC).findList();
    List<Showreel> privatelist =
        find.where().eq("viewable", PRIVATE).eq("user.email", authUser.email).findList();

    List<Showreel> finallist = new ArrayList<Showreel>();
    finallist.addAll(publiclist);
    finallist.addAll(privatelist);

    return finallist;
  }
  /**
   * Replace the path component under the caret with the file selected from the completion list.
   *
   * @param file the selected file.
   * @param caretPos
   * @param start the start offset of the path component under the caret.
   * @param end the end offset of the path component under the caret.
   * @throws BadLocationException
   */
  private void replacePathComponent(LookupFile file, int caretPos, int start, int end)
      throws BadLocationException {
    final Document doc = myPathTextField.getDocument();

    myPathTextField.setSelectionStart(0);
    myPathTextField.setSelectionEnd(0);

    final String name = file.getName();
    boolean toRemoveExistingName;
    String prefix = "";

    if (caretPos >= start) {
      prefix = doc.getText(start, caretPos - start);
      if (prefix.length() == 0) {
        prefix = doc.getText(start, end - start);
      }
      if (SystemInfo.isFileSystemCaseSensitive) {
        toRemoveExistingName = name.startsWith(prefix) && prefix.length() > 0;
      } else {
        toRemoveExistingName =
            name.toUpperCase().startsWith(prefix.toUpperCase()) && prefix.length() > 0;
      }
    } else {
      toRemoveExistingName = true;
    }

    int newPos;
    if (toRemoveExistingName) {
      doc.remove(start, end - start);
      doc.insertString(start, name, doc.getDefaultRootElement().getAttributes());
      newPos = start + name.length();
    } else {
      doc.insertString(caretPos, name, doc.getDefaultRootElement().getAttributes());
      newPos = caretPos + name.length();
    }

    if (file.isDirectory()) {
      if (!myFinder.getSeparator().equals(doc.getText(newPos, 1))) {
        doc.insertString(
            newPos, myFinder.getSeparator(), doc.getDefaultRootElement().getAttributes());
        newPos++;
      }
    }

    if (newPos < doc.getLength()) {
      if (myFinder.getSeparator().equals(doc.getText(newPos, 1))) {
        newPos++;
      }
    }
    myPathTextField.setCaretPosition(newPos);
  }
  private void processChosenFromCompletion(boolean nameOnly) {
    final LookupFile file = getSelectedFileFromCompletionPopup();
    if (file == null) return;

    if (nameOnly) {
      try {
        final Document doc = myPathTextField.getDocument();
        int caretPos = myPathTextField.getCaretPosition();
        if (myFinder.getSeparator().equals(doc.getText(caretPos, 1))) {
          for (; caretPos < doc.getLength(); caretPos++) {
            final String eachChar = doc.getText(caretPos, 1);
            if (!myFinder.getSeparator().equals(eachChar)) break;
          }
        }

        int start = caretPos > 0 ? caretPos - 1 : caretPos;
        while (start >= 0) {
          final String each = doc.getText(start, 1);
          if (myFinder.getSeparator().equals(each)) {
            start++;
            break;
          }
          start--;
        }

        int end = start < caretPos ? caretPos : start;
        while (end <= doc.getLength()) {
          final String each = doc.getText(end, 1);
          if (myFinder.getSeparator().equals(each)) {
            break;
          }
          end++;
        }

        if (end > doc.getLength()) {
          end = doc.getLength();
        }

        if (start > end || start < 0 || end > doc.getLength()) {
          setTextToFile(file);
        } else {
          replacePathComponent(file, caretPos, start, end);
        }
      } catch (BadLocationException e) {
        LOG.error(e);
      }
    } else {
      setTextToFile(file);
    }
  }
 /**
  * Finds all sellers in database and orders them by first name ascending.
  *
  * @return <code>List</code> type value of AppUser
  */
 public static List<AppUser> getAllSellersOrderedByFirstname() {
   return finder
       .where()
       .eq("user_access_level", UserAccessLevel.SELLER)
       .orderBy("firstname asc")
       .findList();
 }
Exemple #13
0
 public static User authenticate(String email, String password) {
   User user = find.where().eq("email", email).findUnique();
   if (user != null && !BCrypt.checkpw(password, user.password)) {
     user = null;
   }
   return user;
 }
 public static List<Event> findRandomCurrentEvents() {
   return find
       // .where()
       // .gt("eventStart",new Date())
       .setMaxRows(4)
       .findList();
 }
  public static TextCustomAttributeValue getOrCreateCustomAttributeValueFromObjectReference(
      Class<?> objectType,
      String filter,
      Long objectId,
      CustomAttributeDefinition customAttributeDefinition) {

    String key = objectType.getName();
    if (filter != null) {
      key += ":" + filter;
    }

    TextCustomAttributeValue customAttributeValue =
        find.where()
            .eq("deleted", false)
            .eq("objectType", key)
            .eq("objectId", objectId)
            .eq("customAttributeDefinition.id", customAttributeDefinition.id)
            .findUnique();
    if (customAttributeValue == null) {
      customAttributeValue = new TextCustomAttributeValue();
      customAttributeValue.objectType = key;
      customAttributeValue.objectId = objectId;
      customAttributeValue.customAttributeDefinition = customAttributeDefinition;
      customAttributeValue.isNotReadFromDb = true;
    }
    return customAttributeValue;
  }
Exemple #16
0
 public static IIndexFragmentFile[] findFiles(
     PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
     throws CoreException {
   String internalRepresentation = strategy.toInternalFormat(location);
   if (internalRepresentation != null) {
     Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1, null);
     btree.accept(finder);
     long[] records = finder.getRecords();
     PDOMFile[] result = new PDOMFile[records.length];
     for (int i = 0; i < result.length; i++) {
       result[i] = recreateFile(pdom, records[i]);
     }
     return result;
   }
   return IIndexFragmentFile.EMPTY_ARRAY;
 }
 public String apply(SUT s) {
   Assert.notNull(s);
   Widget w = finder.apply(s.get(Tags.SystemState));
   Object[] tagValues = new Object[tags.length];
   for (int i = 0; i < tags.length; i++) tagValues[i] = w.get(tags[i], null);
   return String.format(formatString, tagValues);
 }
Exemple #18
0
 static {
   Icon icon = GnomeUtil.getIcon("info", 12, true);
   if (icon == null) {
     icon = Finder.getIcon("images/general/info.png");
   }
   ICON = icon;
 }
Exemple #19
0
 public void update(Object updated) throws ValidationFailureException, EntityNotFoundException {
   log.debug(format("Updating [%s] - %s", updated.getClass().getSimpleName(), updated.toString()));
   validator.validateUpdate(updated);
   Object original = query.findById(updated.getClass(), getPrimaryValueAsLong(updated));
   SQLGenerator sql = new SQLGenerator();
   execute(sql.getUpdateSQL(original, updated));
 }
Exemple #20
0
 /**
  * Return a page
  *
  * @param page Page to display
  * @param pageSize Number of publicacao per page
  * @param sortBy publicacao titulo property used for sorting
  * @param order Sort order (either or asc or desc)
  * @param filter Filter applied on the name column
  */
 public static PagedList<Album> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("titulo", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .findPagedList(page, pageSize);
 }
 public static List<Object> findAllIdsByUserId(Long id) {
   final Query<Event> events = find.where().eq("userAdmin.id", id).select("id");
   if (events != null) {
     return events.findIds();
   }
   return new ArrayList<Object>();
 }
  public static List<Path> searchFiles(Path path, String globPattern) throws IOException {

    if (Files.isDirectory(path)) {
      Finder finder = new Finder(globPattern);
      Files.walkFileTree(path, finder);
      return finder.getPaths();
    } else {
      PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + globPattern);

      if (matcher.matches(path.getFileName())) {
        return Arrays.asList(path);
      } else {
        return Collections.emptyList();
      }
    }
  }
Exemple #23
0
 /**
  * 주어진 {@code attach}와 내용이 같은 첨부 파일을 찾는다.
  *
  * <p>내용이 같은 첨부 파일이라고 하는 것은 이름과 파일의 내용이 같고 첨부된 리소스도 같은 것을 말한다. 구체적으로 말하면 {@link Attachment#name},
  * {@link Attachment#hash}, {@link Attachment#containerType}, {@link Attachment#containerId}가 서로
  * 같은 첨부이다.
  *
  * @param attach 이 첨부 파일과 내용이 같은 첨부 파일을 찾는다.
  * @return 발견된 첨부 파일
  */
 private static Attachment findBy(Attachment attach) {
   return find.where()
       .eq("name", attach.name)
       .eq("hash", attach.hash)
       .eq("containerType", attach.containerType)
       .eq("containerId", attach.containerId)
       .findUnique();
 }
Exemple #24
0
 public static Page<Office> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("name", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .findPagingList(pageSize)
       .getPage(page);
 }
Exemple #25
0
 public static int getTotalPrivateSearchPageCount(String searchTerm, String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
 public static <T extends UserAction> int countBy(
     Finder<Long, T> finder, ResourceType resourceType, String resourceId) {
   return finder
       .where()
       .eq("resourceType", resourceType)
       .eq("resourceId", resourceId)
       .findRowCount();
 }
 public static Event findByIdWithMin(Long id) {
   return find.where()
       .eq("id", id)
       .select(
           "id, heroImgUrl, eventEnd, eventStart, slug, status, schoolId, fundraisingEnd, fundraisingStart, goal, name, userAdmin")
       .fetch("userAdmin")
       .findUnique();
 }
  public static void main(String args[]) throws IOException, RecognitionException {

    JavaParserRunner javaParserTest = new JavaParserRunner();
    if (args.length != 2) return;
    String startingDir = args[0];
    String filePattern = args[1];
    Finder finder = new Finder(filePattern);
    List<File> files = finder.getMatchingFiles(startingDir);
    System.out.println("SIZE=" + files.size());
    for (File file : files) {
      System.out.println("Handling " + file.getCanonicalPath());
      javaParserTest.runParser(file.getCanonicalPath());
      javaParserTest.runEntityExtractor();
      javaParserTest.runInheritanceExtractor();
      javaParserTest.runCBOCalculator();
    }
  }
 /**
  * Return a plugin registration or null if not found
  *
  * @param pluginConfigurationId the Id of the plugin configuration
  * @param dataType the type of the BizDock object
  * @param internalId the Id of the object
  * @return a boolean
  */
 public static PluginRegistration getPluginRegistration(
     Long pluginConfigurationId, DataType dataType, Long internalId) {
   return find.where()
       .eq("pluginConfiguration.id", pluginConfigurationId)
       .eq("dataType", dataType.getDataTypeClassName())
       .eq("internalId", internalId)
       .findUnique();
 }
 /**
  * Extended find interface used in situations where the implementator may or may not be able to
  * answer the complete query. It will attempt to answer the pattern but if its answers are not
  * known to be complete then it will also pass the request on to the nested Finder to append more
  * results.
  *
  * @param pattern a TriplePattern to be matched against the data
  * @param continuation either a Finder or a normal Graph which will be asked for additional match
  *     results if the implementor may not have completely satisfied the query.
  */
 @Override
 public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) {
   if (graph == null) return new NullIterator<Triple>();
   if (continuation == null) {
     return graph.find(pattern.asTripleMatch());
   } else {
     return graph.find(pattern.asTripleMatch()).andThen(continuation.find(pattern));
   }
 }