Topic
2 replies Latest Post - ‏2014-09-30T21:45:48Z by Babin_AG
SystemAdmin
SystemAdmin
648 Posts
ACCEPTED ANSWER

Pinned topic rollback

‏2012-11-10T09:16:54Z |
It is aware that catalog rollback would not rollback spec. How to rollback spec?
Updated on 2012-11-21T01:19:33Z at 2012-11-21T01:19:33Z by KaranBal
  • KaranBal
    KaranBal
    108 Posts
    ACCEPTED ANSWER

    Re: rollback

    ‏2012-11-21T01:19:33Z  in response to SystemAdmin
    Hi Frank,
    As you know specs are not dedicated to a catalog; the same spec can be shared amongst numerous catalogs and that is part of why rolling back a spec will not rollback the spec. Also, I am not aware of any way to rollback a spec to a previous version within MDMCS. A reason for that may be the possibility of lost data if the the specs are changed to a previous value but catalog is the same. If you really want to rollback spec, then you may do so via:
    1. Work with your DBA to rollback the entire database. This is drastic but it will restore the specs to an earlier versions.
    2. Rollback spec specific tables i.e. TCTG_SPA_SPEC_ATTRIBUTES and TCTG_SPC_SPECIFICATION. This may lead to lost data in items.

    But maybe someone else knows of a better way to achieve this without resorting to the database level rollbacks.
    • Babin_AG
      Babin_AG
      10 Posts
      ACCEPTED ANSWER

      Re: rollback

      ‏2014-09-30T21:45:48Z  in response to KaranBal
                  //get spec id with sql "select * from TCTG_SPC_SPECIFICATION where spc_name = 'spc_name'"
                  //get versionId of spec version to rollback to from sql "select * from TCTG_VER_VERSION where ver_object_id = spec_id"
                  IMutableSpec mutableByIdVersion = SpecLoader.getMutableByIdVersion(spec_id, version_id__rollback_to);
                  MutableSpec rollbackToThisVersion = (MutableSpec) mutableByIdVersion;
                  IMutableSpec mutableByIdVersion2 = SpecLoader.getMutableById(spec_id);
                  MutableSpec latestVersionToRollback = (MutableSpec) mutableByIdVersion2;
                  for (Object toRemove : latestVersionToRollback.getNodeList()) {
                      INode iNode = (INode) toRemove;
                      String path = iNode.getPath();
                      latestVersionToRollback.removeNode(path);
                  }
                  for (Object toAdd : rollbackToThisVersion.getNodeList()) {
                      IMutableNode iNode = (IMutableNode) toAdd;
                      latestVersionToRollback.addNode(iNode);
                  }
                  latestVersionToRollback.setLocalized(rollbackToThisVersion.isLocalized());
                  latestVersionToRollback.removeLocales(latestVersionToRollback.getLocales());
                  latestVersionToRollback.setLocales(new ArrayList(rollbackToThisVersion.getLocales()));
                  latestVersionToRollback.toDB(2);

      This code can rollback spec to version you need. If there were no modifications in containers that based on that spec, all lost values will appear.