V1_0.java [src/java/m/rv/editsynonyms] Revision: default  Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API, and application suite.
 *
 * 2012-2022, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package m.rv.editsynonyms;

import csip.ModelDataService;
import csip.annotations.Description;
import csip.annotations.Name;
import csip.annotations.VersionInfo;
import edit.EditConnection;
import edit.EditQueries;
import java.util.Map;
import javax.ws.rs.Path;

/**
 *
 */
@Name("Get ESID mapping")
@Description("Returns the new esId, if there is any.")
@VersionInfo("1.0")
@Path("d/esid/1.0")
public class V1_0 extends ModelDataService {

  @Override
  protected void doProcess() throws Exception {
    String esId = parameter().getString("esId");

    EditConnection edit = new EditConnection(LOG);
    Map<String, String> s = EditQueries.getSynonymEntry(edit.fetchAllSynonyms(), esId);

    results().put("old", esId);
    if (s != null) {
      results().put("new", s.get("legacyId"));
      results().put("date", s.get("date"));
      results().put("geoUnit", s.get("geoUnit"));
    }
  }

}