/bark-core/src/main/java/com/ebay/oss/bark/repo/DataAssetRepoImpl.java

https://github.com/zlfsimon/DQSolution · Java · 47 lines · 23 code · 8 blank · 16 comment · 0 complexity · 0bc27ad3337fd1f1e40d8b2d8d65ef09 MD5 · raw file

  1. /*
  2. Copyright (c) 2016 eBay Software Foundation.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.ebay.oss.bark.repo;
  14. import org.springframework.stereotype.Repository;
  15. import com.ebay.oss.bark.domain.DataAsset;
  16. import com.google.gson.Gson;
  17. import com.mongodb.DBObject;
  18. import com.mongodb.util.JSON;
  19. @Repository
  20. public class DataAssetRepoImpl extends BaseIdRepo<DataAsset> implements DataAssetRepo {
  21. public DataAssetRepoImpl() {
  22. super("data_assets", "DQ_DATA_ASSET_SEQ_NO", DataAsset.class);
  23. }
  24. @Override
  25. public void update(DataAsset entity, DBObject old) {
  26. Gson gson = new Gson();
  27. // DBObject t1 = gson.fromJson(gson.toJson(entity),
  28. // BasicDBObject.class);
  29. DBObject t1 = (DBObject) JSON.parse(gson.toJson(entity));
  30. dbCollection.remove(old);
  31. dbCollection.save(t1);
  32. }
  33. @Override
  34. protected DataAsset toEntity(DBObject o) {
  35. return new DataAsset(o);
  36. }
  37. }