Rule 2: Check unique artifactId's
764843
function () {
      var doUniqueArtifactIdsCheck = function (artifactsIds) {
        var duplicateArtifactIds = [];
        artifactsIds.forEach(function (artifactId) {
          var artifactIdUnderTest = artifactId;

          function filterById (id) {
            return id === artifactIdUnderTest;
          }

          var arrayByUniqueArtifactIds = artifactsIds.filter(filterById);
          if (arrayByUniqueArtifactIds.length > 1 && duplicateArtifactIds.indexOf(artifactIdUnderTest) < 0) {
            duplicateArtifactIds.push(artifactIdUnderTest);
          }
        });
        duplicateArtifactIds.forEach(function (artifactId) {
          errors.push(
            'RuleViolation identified: WebPackage contains multiple artifacts with \'artifactId\'=\'' +
            artifactId + '\'');
        });
      };
      //
      var collectArtifactIds = function (next) {
        var artifactsIds = [];
        if (doc.artifacts) {
          Object.keys(doc.artifacts).forEach(function (artifactType) {
            doc.artifacts[ artifactType ].forEach(function (artifact) {
              artifactsIds.push(artifact.artifactId);
            });
          });
        }
        next(artifactsIds);
      };
      collectArtifactIds(doUniqueArtifactIdsCheck);
    }
1181697
function ruleUnique($table, $field, $ignore_id = null, $error_message = null) {
        $suffix = $table . ',' . $field;
        if ($ignore_id) {
            $suffix .= ',' . $ignore_id;
        }

        return $this->_rule('unique:' . $suffix, $error_message);
    }
390711
def _MigrateArtifact(artifact):
  """"""
  name = Text(artifact.name)

  try:
    logging.info("Migating %s", name)
    data_store.REL_DB.WriteArtifact(artifact)
    logging.info("  Wrote %s", name)
  except db.DuplicatedArtifactError:
    logging.info("  Skipped %s, because artifact already exists.", name)
558044
def has_calmjs_artifact_declarations(cmd, registry_name='calmjs.artifacts'):
    

    return any(get(registry_name).iter_records_for(
        cmd.distribution.get_name()))
431586
protected boolean filterUnwantedArtifacts(Artifact artifact) {
        // filter out maven and plexus stuff (plexus used by maven plugins)
        if (artifact.getGroupId().startsWith("org.apache.maven")) {
            return true;
        } else if (artifact.getGroupId().startsWith("org.codehaus.plexus")) {
            return true;
        }

        return false;
    }
1027773
def get_unique_name(name='', collection=()):
    '''
    
    '''
    if name not in collection:
        return name
    i = 1
    while True:
        i += 1
        name2 = '%s_%s' % (name, i)
        if name2 not in collection:
            return name2
731950
def _generate_id(self):
        
        name = self.name.replace(self.special_separator, "-").replace(".", "-")
        loc = "\/"
        if self.location:
            loc = self.location
        _id = "{PREFIX}{SEP}{NAME}{HASH}{SEP}".format(
            PREFIX=constants.CONU_ARTIFACT_TAG,
            NAME=name,
            HASH=hashlib.sha512(loc).hexdigest()[: 10],
            SEP=self.special_separator
        )
        return _id
89252
@Override
    public List<String> findVersions(final Artifact artifact) {
        return Arrays.asList(new String[]{artifact.getVersion()});
    }
338371
function validateUniqueness(attr, conf, err, done) {
    var cond = {where: {}};
    cond.where[attr] = this[attr];
    this.constructor.all(cond, function (error, found) {
        if (found.length > 1) {
            err();
        } else if (found.length === 1 && (!this.id || !found[0].id || found[0].id.toString() !== this.id.toString())) {
            err();
        }
        done();
    }.bind(this));
}
200778
def detect_uniqueness_error(self, exc):
        
        pattern = r"(\w+) with this (\w+) already exists"

        fields = []
        if isinstance(exc, IntegrityError):
            return self._detect_integrity_error(exc)
        assert isinstance(exc, ValidationError), TypeError

        for name, err in exc.error_dict.items():
            if re.search(pattern, str(err)):
                fields.append(name)
        return fields or None
1222656
def _isRepositoryReady(self):
        """"""
        return os.path.exists(os.path.join(self._absWorkdir(), '.hg'))
472936
def duplicate_ids(instance):
    
    if instance['type'] != 'bundle' or 'objects' not in instance:
        return

    unique_ids = {}
    for obj in instance['objects']:
        if 'id' not in obj or 'modified' not in obj:
            continue
        elif obj['id'] not in unique_ids:
            unique_ids[obj['id']] = obj['modified']
        elif obj['modified'] == unique_ids[obj['id']]:
            yield JSONError("Duplicate ID '%s' has identical `modified` timestamp."
                            " If they are different versions of the same object, "
                            "they should have different `modified` properties."
                            % obj['id'], instance['id'], 'duplicate-ids')
488477
def list_dependency_artifacts(id, page_size=200, page_index=0, sort="", q=""):
    
    data = list_dependency_artifacts_raw(id, page_size, page_index, sort, q)
    if data:
        return utils.format_json_list(data)
556396
private void addNewArtifactsItems(List<BaseArtifact> baseArtifacts, List<ArtifactItem> existingArtifactItems, ArtifactoryCollector collector) {
        long start = System.currentTimeMillis();
        List<BinaryArtifact> binaryArtifacts = new ArrayList<>();
        int count = 0;
        Set<ArtifactItem> existingSet = new HashSet<>(existingArtifactItems);
        for (BaseArtifact baseArtifact : baseArtifacts) {
            ArtifactItem newArtifactItem = baseArtifact.getArtifactItem();
            if (newArtifactItem != null && !existingSet.contains(newArtifactItem)) {
                newArtifactItem.setLastUpdated(System.currentTimeMillis());
                newArtifactItem.setCollectorId(collector.getId());
                newArtifactItem = artifactItemRepository.save(newArtifactItem);
                existingSet.add(newArtifactItem);
                BinaryArtifact binaryArtifact = baseArtifact.getBinaryArtifact();
                if (binaryArtifact != null) {
                    binaryArtifact.setCollectorItemId(newArtifactItem.getId());
                    binaryArtifacts.add(binaryArtifact);
                }
                count++;
            }
        }
        if (!binaryArtifacts.isEmpty()) {
            binaryArtifacts.forEach(binaryArtifact -> binaryArtifactRepository.save(binaryArtifact));
        }
        log("New artifacts", start, count);
    }
411742
def check(self):
        """"""

        for i in [f for fs in [self.networks, self.ansible_hosts, self.systems, self.deploys,
                               self.configures, [self.contextualize]] for f in fs]:
            i.check(self)

        snames = [s.name for s in self.systems]
        if len(set(snames)) != len(snames):
            raise RADLParseException("Some System name duplicated.")

        nids = [s.id for s in self.networks]
        if len(set(nids)) != len(nids):
            raise RADLParseException("Some Network name duplicated.")

        return True
39109
private void validateDepNameUniqueness(final List<TriggerDependencyBean> dependencies) {
    final Set<String> seen = new HashSet<>();
    for (final TriggerDependencyBean dep : dependencies) {
      // set.add() returns false when there exists duplicate
      Preconditions.checkArgument(seen.add(dep.getName()), String.format("duplicate dependency"
          + ".name %s found, dependency.name should be unique", dep.getName()));
    }
  }
1045608
def _CollectArtifact(self, artifact, apply_parsers):
    """"""
    artifact_result = rdf_artifacts.CollectedArtifact(name=artifact.name)

    if apply_parsers:
      parser_factory = parsers.ArtifactParserFactory(str(artifact.name))
    else:
      parser_factory = None

    for source_result_list in self._ProcessSources(artifact.sources,
                                                   parser_factory):
      for response in source_result_list:
        action_result = rdf_artifacts.ClientActionResult()
        action_result.type = response.__class__.__name__
        action_result.value = response
        artifact_result.action_results.append(action_result)
        self.UpdateKnowledgeBase(response, artifact.provides)

    return artifact_result