Exemplo n.º 1
0
  public DesignServiceManager() throws JAXBException, IOException {

    this.serviceDefinitions = new HashMap<Project, Map<String, Service>>();

    Unmarshaller unmarshaller = definitionsContext.createUnmarshaller();
    ClassPathResource primitiveServiceFile =
        new ClassPathResource("com/wavemaker/tools/service/primitive_types.xml");
    InputStream inputStream = primitiveServiceFile.getInputStream();
    try {
      Service primitiveService = (Service) unmarshaller.unmarshal(inputStream);
      this.primitiveTypes =
          Collections.unmodifiableList(primitiveService.getDataobjects().getDataobject());

      Map<String, String> m = new TreeMap<String, String>();

      for (DataObject o : this.primitiveTypes) {
        if (!o.isInternal()) {
          m.put(o.getName(), o.getJavaType());
        }
      }

      this.primitivesMap = Collections.unmodifiableMap(m);
    } finally {
      inputStream.close();
    }
  }
Exemplo n.º 2
0
  public void saveServiceDefinition(String serviceId) {

    Resource serviceDefFile = getServiceDefXml(serviceId, false);
    Service service = getCurrentServiceDefinition(serviceId);

    Service oldService = null;
    if (serviceId.equals(CommonConstants.SALESFORCE_SERVICE)) {
      // For salesforceService, we need to retain service definitions in
      // the old service definition file.
      oldService = loadServiceDefinition(serviceId);

      if (oldService != null) {
        for (Operation op : oldService.getOperation()) {
          if (isDeletedQuery(op)) {
            this.cfg.removeDeletedSFQueries(op.getName());
            continue;
          }
          service.addOperation(op);
        }

        List<DataObject> dataObjects = service.getDataobjects().getDataobject();
        for (DataObject dobj : oldService.getDataobjects().getDataobject()) {
          if (isDeletedSFDataObject(dobj)) {
            this.cfg.removeDeletedSFDataObjects(dobj.getName());
            continue;
          }
          dataObjects.add(dobj);
        }

        service.setType(oldService.getType());
        service.setCRUDService(oldService.getCRUDService());
      }
    } // salesforce
    try {
      Marshaller marshaller = definitionsContext.createMarshaller();
      marshaller.setProperty("jaxb.formatted.output", true);
      OutputStream outputStream = this.fileSystem.getOutputStream(serviceDefFile);
      try {
        marshaller.marshal(service, outputStream);
      } finally {
        try {
          outputStream.close();
        } catch (IOException e) {
          throw new IllegalStateException("Unable to close service def file", e);
        }
      }
      // XXX MAV-569 should do a real build here, or actually outside
      // this method maybe
      SortedSet<Service> s = new TreeSet<Service>(new ServiceComparator());
      s.add(service);
      generateRuntimeConfiguration(s);
    } catch (JAXBException e) {
      throw new WMRuntimeException(e);
    } catch (IOException e) {
      throw new WMRuntimeException(e);
    } catch (NoSuchMethodException e) {
      throw new WMRuntimeException(e);
    }
  }