示例#1
0
  public RepositoryTagMap(
      AbstractRepository repository,
      RepositoryTagMap parent,
      Map<String, RepositoryTagEntry> tagMap)
      throws IOException {
    _tagMap = Collections.unmodifiableMap(tagMap);

    long now = Alarm.getCurrentTime();

    if (parent.getSequence() < now) _sequence = now;
    else _sequence = parent.getSequence() + 1;

    TempStream os = new TempStream();
    WriteStream out = new WriteStream(os);

    writeTagMap(out);
    out.close();

    String tagHash;

    InputStream is = os.getInputStream();

    try {
      tagHash = repository.addBlob(is);
    } finally {
      is.close();
    }

    _tree = new GitTree();

    _tree.addBlob("tags", 0775, tagHash);

    for (String key : tagMap.keySet()) {
      RepositoryTagEntry entry = tagMap.get(key);

      String sha1 = entry.getTagEntryHash();
      String root = entry.getRoot();

      _tree.addBlob(sha1, 0644, sha1);

      GitType type = repository.getType(root);

      if (type == GitType.BLOB) _tree.addBlob(root, 0644, root);
      else if (type == GitType.TREE) _tree.addDir(root, root);
      else throw new IllegalStateException(L.l("'{0}' has an unknown type {1}", root, type));
    }

    String treeHash = repository.addTree(_tree);

    _commit = new GitCommit();
    _commit.setTree(treeHash);
    _commit.put("sequence", String.valueOf(_sequence));

    _commitHash = repository.addCommit(_commit);
  }
  @Override
  public ArticuloEntity save(ArticuloEntity entidad) {

    if (entidad.getCodigo() == null) {
      super.save(entidad);

    } else {

      super.merge(entidad);
    }

    return entidad;
  }
示例#3
0
 public void listAll() {
   List<Person> list = pr.findAll();
   System.out.println("查询结果如下:");
   for (Person p : list) {
     System.out.println(p.toString());
   }
 }
示例#4
0
 /**
  * This function obtains from a predicate that is a conjunction of assignments the assignment
  * related to an identifier
  *
  * @param specID The identifier of a variable in the specification
  * @param pred A predicate
  * @return the equality
  */
 public static MemPred getRelatedEquality(Pred pred, String specID) {
   AbstractRepository<Pred> predRep = pred.accept(new AndPredClausesExtractor());
   AbstractIterator<Pred> predIt = predRep.createIterator();
   while (predIt.hasNext()) {
     Pred auxPred = predIt.next();
     if (auxPred instanceof MemPred) {
       MemPred memPred = ((MemPred) auxPred);
       if (memPred.getMixfix()) {
         String id = ((RefExpr) memPred.getLeftExpr()).getName().toString();
         if (id.equals(specID)) {
           return memPred;
         }
       } else return null;
     } else return null;
   }
   return null;
 }
  @Override
  public void expireCaches(ResourceStoreRequest request) {
    final List<Repository> members = getMemberRepositories();
    for (Repository member : members) {
      member.expireCaches(request);
    }

    super.expireCaches(request);
  }
 @Override
 public void maintainNotFoundCache(ResourceStoreRequest request) throws ItemNotFoundException {
   // just maintain the cache (ie. expiration), but don't make NFC
   // affect call delegation to members
   try {
     super.maintainNotFoundCache(request);
   } catch (ItemNotFoundException e) {
     // ignore it
   }
 }
示例#7
0
  protected void getResources(List<Resource> list, boolean recursive) throws IOException {
    Set paths = context.getResourcePaths(path);

    if (paths != null) {
      for (Object obj : paths) {
        String path = (String) obj;
        if (!path.endsWith("/")) {
          int n = path.lastIndexOf('/', path.length() - 1);
          String name = path.substring(n + 1);
          list.add(lookupResource(name));
        } else if (recursive) {
          int n = path.lastIndexOf('/', path.length() - 2);
          String name = path.substring(n + 1, path.length() - 1);
          AbstractRepository repo = lookupRepository(name);
          repo.getResources(list, true);
        }
      }
    }
  }
示例#8
0
  public RepositoryTagMap(AbstractRepository repository, String commitHash, boolean isValidate)
      throws IOException {
    _commitHash = commitHash;

    if (commitHash == null) throw new NullPointerException();

    // force loading and validation from backend
    if (isValidate) repository.validateHash(commitHash);

    _commit = repository.readCommit(commitHash);

    String sequence = _commit.get("sequence");

    if (sequence != null) _sequence = Long.parseLong(sequence);
    else _sequence = 1;

    _tree = repository.readTree(_commit.getTree());

    _tagMap = readTagMap(repository, _tree.getHash("tags"));
  }
  @Override
  protected void prepareForSave() throws ConfigurationException {
    super.prepareForSave();

    boolean membersChanged = false;
    List<String> currentMemberIds = Collections.emptyList();
    List<String> newMemberIds = Collections.emptyList();

    if (isConfigured()) {
      // we must do this before the super.onEvent() call!
      // members changed if config was dirty AND the "old" and "new" member ID list (List<String>)
      // are NOT equal
      membersChanged =
          getCurrentCoreConfiguration().isDirty()
              && !getExternalConfiguration(false)
                  .getMemberRepositoryIds()
                  .equals(getExternalConfiguration(true).getMemberRepositoryIds());

      // we have to "remember" these before commit happens in super.onEvent
      // but ONLY if we are dirty and we do have "member changes" (see membersChanged above)
      // this same boolean drives the firing of the event too, for which we are actually collecting
      // these lists
      // if no event to be fired, these lines should also not execute, since they are "dirtying" the
      // config
      // if membersChange is true, config is already dirty, and we DO KNOW there is member change to
      // happen
      // and we will fire the event too
      if (membersChanged) {
        currentMemberIds = getExternalConfiguration(false).getMemberRepositoryIds();
        newMemberIds = getExternalConfiguration(true).getMemberRepositoryIds();
      }
    }

    if (membersChanged) {
      // fire another event
      eventBus().post(new RepositoryGroupMembersChangedEvent(this, currentMemberIds, newMemberIds));
    }
  }
示例#10
0
  private Map<String, RepositoryTagEntry> readTagMap(AbstractRepository repository, String sha1)
      throws IOException {
    TreeMap<String, RepositoryTagEntry> map = new TreeMap<String, RepositoryTagEntry>();

    InputStream is = repository.openBlob(sha1);
    try {
      ReadStream in = Vfs.openRead(is);

      String tag;

      while ((tag = in.readLine()) != null) {
        String entrySha1 = in.readLine();

        RepositoryTagEntry entry = new RepositoryTagEntry(repository, entrySha1);

        map.put(tag, entry);
      }
    } finally {
      is.close();
    }

    return Collections.unmodifiableMap(map);
  }
示例#11
0
 public void findOne() {
   String id = "5338e1cdf6bfc8a01e233b4d";
   Person p = pr.findOne(id);
   System.out.println(p);
 }
示例#12
0
 public void insert() {
   Person p = new Person("cuiran", 27);
   pr.insert(p);
   System.out.println("添加成功");
 }
  @Override
  public void delete(ArticuloEntity entidad) {

    super.delete(find(entidad.getCodigo()));
  }