private static SortedMap<String, PropertyValue> createVariantProps(RecordId recordId) { if (recordId == null) { return null; } SortedMap<String, PropertyValue> variantProps = null; if (!recordId.isMaster()) { variantProps = new TreeMap<String, PropertyValue>(); for (Map.Entry<String, String> entry : recordId.getVariantProperties().entrySet()) { variantProps.put(entry.getKey(), new PropertyValue(PropertyMode.SET, entry.getValue())); } } return variantProps; }
@Override public RecordId newRecordId(RecordId masterRecordId, Map<String, String> variantProperties) { ArgumentValidator.notNull(masterRecordId, "masterRecordId"); ArgumentValidator.notNull(variantProperties, "variantProperties"); if (!masterRecordId.isMaster()) { throw new IllegalArgumentException("Specified masterRecordId is a variant record ID."); } if (variantProperties.isEmpty()) { return masterRecordId; } checkReservedCharacters(variantProperties); return new VariantRecordId(masterRecordId, variantProperties, this); }
@Override public void follow(IndexUpdateBuilder indexUpdateBuilder, FollowCallback callback) throws RepositoryException, IOException, InterruptedException { RecordContext ctx = indexUpdateBuilder.getRecordContext(); if (ctx.dep.id.isMaster()) { // We're already on a master record, stop here return; } LRepository repository = indexUpdateBuilder.getRepository(); LTable table = repository.getTable(indexUpdateBuilder.getTable()); Dep masterDep = new Dep(ctx.dep.id.getMaster(), Collections.<String>emptySet()); Record master = null; try { master = VersionTag.getIdRecord(masterDep.id, indexUpdateBuilder.getVTag(), table, repository); } catch (RecordNotFoundException e) { // It's ok that the master does not exist } catch (VersionNotFoundException e) { // It's ok that the master does not exist } indexUpdateBuilder.push(master, masterDep); callback.call(); indexUpdateBuilder.pop(); }