/** * Get UUID from database if it exists, otherwise generate a new one. */ @Override public String getOrCreateForKey(String key) { return uuidsByKey.computeIfAbsent(key, k -> Uuids.create()); } }
private String insertQualityGate() { String uuid = Uuids.createFast(); db.executeInsert( "quality_gates", "UUID", uuid, "NAME", uuid, "IS_BUILT_IN", String.valueOf(false), "CREATED_AT", new Date(PAST), "UPDATED_AT", new Date(PAST)); return uuid; }
private void insertQualityGate(String name, boolean builtIn) { db.executeInsert( "QUALITY_GATES", "UUID", Uuids.createFast(), "NAME", name, "IS_BUILT_IN", String.valueOf(builtIn), "CREATED_AT", new Date(PAST), "UPDATED_AT", new Date(PAST)); } }
/** * Get UUID from component having the same key in database if it exists, otherwise look for migrated keys, and finally generate a new one. */ @Override public String getOrCreateForKey(String key) { return uuidsByDbKey.computeIfAbsent(key, k1 -> uuidsByMigratedKey.computeIfAbsent(k1, k2 -> Uuids.create())); } }
private String insertRulesProfiles(String name, String language, Boolean isBuiltIn) { String uuid = Uuids.createFast(); db.executeInsert("RULES_PROFILES", "NAME", name, "LANGUAGE", language, "KEE", uuid, "CREATED_AT", new Timestamp(PAST), "UPDATED_AT", new Timestamp(PAST), "IS_BUILT_IN", isBuiltIn); return uuid; }
Object of(Object component, Logger log) { if (component instanceof Class) { return component; } String key = component.toString(); if (IDENTITY_HASH_PATTERN.matcher(key).matches()) { if (!objectsWithoutToString.add(component.getClass())) { log.warn(String.format("Bad component key: %s. Please implement toString() method on class %s", key, component.getClass().getName())); } key += Uuids.create(); } return new StringBuilder().append(component.getClass().getCanonicalName()).append("-").append(key).toString(); } }
private String insertOrgQProfiles(String organizationUuid, String rulesProfileUuid) { String uuid = Uuids.createFast(); db.executeInsert("ORG_QPROFILES", "UUID", uuid, "ORGANIZATION_UUID", organizationUuid, "RULES_PROFILE_UUID", rulesProfileUuid, "CREATED_AT", PAST, "UPDATED_AT", PAST); return uuid; }
/** * Similar to {@link #insertOrUpdate(DbSession, LiveMeasureDto)}, except that: * <ul> * <li>it is batch session friendly (single same statement for both updates and inserts)</li> * <li>it triggers a single SQL request</li> * </ul> * <p> * <strong>This method should not be called unless {@link Dialect#supportsUpsert()} is true</strong> */ public int upsert(DbSession dbSession, LiveMeasureDto dto) { return mapper(dbSession).upsert(dto, Uuids.create(), system2.now()); }
public static ComponentDto newSubView(ComponentDto viewOrSubView) { String uuid = Uuids.createFast(); return newSubView(viewOrSubView, uuid, "KEY_" + uuid); }
public void insert(DbSession dbSession, LiveMeasureDto dto) { mapper(dbSession).insert(dto, Uuids.create(), system2.now()); }
private void insertProject(String organizationUuid, boolean isPrivate) { String uuid = Uuids.createFast(); db.executeInsert("PROJECTS", "ORGANIZATION_UUID", organizationUuid, "KEE", uuid + "-key", "UUID", uuid, "PROJECT_UUID", uuid, "MAIN_BRANCH_PROJECT_UUID", uuid, "UUID_PATH", ".", "ROOT_UUID", uuid, "PRIVATE", Boolean.toString(isPrivate), "SCOPE", "PRJ", "QUALIFIER", "PRJ"); }
public void insertOrUpdate(DbSession dbSession, LiveMeasureDto dto) { LiveMeasureMapper mapper = mapper(dbSession); long now = system2.now(); if (mapper.update(dto, now) == 0) { mapper.insert(dto, Uuids.create(), now); } }
public static ComponentDto newFileDto(ComponentDto subProjectOrProject, @Nullable ComponentDto directory) { return newFileDto(subProjectOrProject, directory, Uuids.createFast()); }
@Test public void create_unique() { Set<String> all = new HashSet<>(); for (int i = 0; i < 50; i++) { String uuid = Uuids.create(); assertThat(uuid).isNotEmpty(); all.add(uuid); } assertThat(all).hasSize(50); }
public static ComponentDto newDirectory(ComponentDto module, String path) { return newDirectory(module, Uuids.createFast(), path); }
public static DefaultIssueComment create(String issueKey, @Nullable String userUuid, String markdownText) { DefaultIssueComment comment = new DefaultIssueComment(); comment.setIssueKey(issueKey); comment.setKey(Uuids.create()); Date now = new Date(); comment.setUserUuid(userUuid); comment.setMarkdownText(markdownText); comment.setCreatedAt(now).setUpdatedAt(now); comment.setNew(true); return comment; }
private String insertOrganization() { String uuid = Uuids.createFast(); db.executeInsert("ORGANIZATIONS", "UUID", uuid, "KEE", uuid, "NAME", uuid, "SUBSCRIPTION", "PAID", "GUARDED", false, "DEFAULT_QUALITY_GATE_UUID", "QGATE_UUID", "NEW_PROJECT_PRIVATE", false, "CREATED_AT", PAST, "UPDATED_AT", PAST); return uuid; }
@Test public void create_from_scratch_creates_ServerId_from_JDBC_URL_and_new_uuid() { String jdbcUrl = "jdbc"; String uuid = Uuids.create(); String sanitizedJdbcUrl = "sanitized_jdbc"; settings.setProperty(JDBC_URL.getKey(), jdbcUrl); when(uuidFactory.create()).thenReturn(uuid); when(jdbcUrlSanitizer.sanitize(jdbcUrl)).thenReturn(sanitizedJdbcUrl); ServerId serverId = underTest.create(); assertThat(serverId.getDatabaseId().get()).isEqualTo(crc32Hex(sanitizedJdbcUrl)); assertThat(serverId.getDatasetId()).isEqualTo(uuid); }
private String insertOrganization(@Nullable String defaultQualityGateUuid) { String uuid = Uuids.createFast(); db.executeInsert( "organizations", "UUID", uuid, "KEE", uuid, "NAME", uuid, "GUARDED", String.valueOf(false), "NEW_PROJECT_PRIVATE", String.valueOf(true), "DEFAULT_QUALITY_GATE_UUID", defaultQualityGateUuid, "CREATED_AT", PAST, "UPDATED_AT", PAST); return uuid; }
public void copyExistingOpenIssueFromLongLivingBranch(DefaultIssue raw, DefaultIssue base, String fromLongBranchName) { raw.setKey(Uuids.create()); raw.setNew(false); copyAttributesOfIssueFromOtherBranch(raw, base); raw.setFieldChange(changeContext, IssueFieldsSetter.FROM_LONG_BRANCH, fromLongBranchName, analysisMetadataHolder.getBranch().getName()); }