Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.MetadataRelationRepository


                params, context, Params.PARENT_UUID, Params.PARENT_ID));
    int childId = Integer.parseInt(Utils.getIdentifierFromParameters(
        params, context, Params.CHILD_UUID, Params.CHILD_ID));

        final Specifications<MetadataRelation> spec = where(hasMetadataId(parentId)).and(hasRelatedId(childId));
        final MetadataRelationRepository metadataRelationRepository = context.getBean(MetadataRelationRepository.class);
        final long count = metadataRelationRepository.count(spec);

        boolean exist = false;
    if (count == 1) {
      exist = true;
    } else {
            MetadataRelation entity = new MetadataRelation().setId(new MetadataRelationId(parentId, childId));
            metadataRelationRepository.save(entity);
    }
   
    Element response = new Element(Jeeves.Elem.RESPONSE)
        .setAttribute("alreadyExist", String.valueOf(exist))
        .addContent(
View Full Code Here


  /**
   * Run the query and load a Set based on query results.
   */
  private static Set<Integer> retrieveIds(ServiceContext context, boolean findMetadataId,
      String field, int id) throws SQLException {
        final MetadataRelationRepository relationRepository = context.getBean(MetadataRelationRepository.class);

        Specification<MetadataRelation> spec;
        if (findMetadataId) {
            spec = MetadataRelationSpecs.hasMetadataId(id);
        } else {
            spec = MetadataRelationSpecs.hasRelatedId(id);
        }

        HashSet<Integer> results = new HashSet<Integer>();
        for (MetadataRelation metadataRelation : relationRepository.findAll(spec)) {
            if (findMetadataId) {
                results.add(metadataRelation.getId().getMetadataId());
            } else {
                results.add(metadataRelation.getId().getRelatedId());
            }
View Full Code Here

    int parentId = Integer.parseInt(Utils.getIdentifierFromParameters(
                params, context, Params.PARENT_UUID, Params.PARENT_ID));
    int childId = Integer.parseInt(Utils.getIdentifierFromParameters(
        params, context, Params.CHILD_UUID, Params.CHILD_ID));

        final MetadataRelationRepository relationRepository = context.getBean(MetadataRelationRepository.class);
        relationRepository.delete(new MetadataRelationId(parentId, childId));

    return new Element(Jeeves.Elem.RESPONSE);
  }
View Full Code Here

TOP

Related Classes of org.fao.geonet.repository.MetadataRelationRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.